Skip to content

Commit 89148a4

Browse files
committed
2 parents 185caf1 + 989c654 commit 89148a4

File tree

8 files changed

+17
-18
lines changed

8 files changed

+17
-18
lines changed

JavaScript/src/bloom_filter/bloom_filter.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const LN_2 = Math.log(2);
2626
* @private
2727
* @description
2828
* Read a bit from the internal storage.
29-
*
29+
*
3030
* @param {!Uint8Array} bitsArray An array containing all the bits for the filter, broken down by the byte.
3131
* @param {!Number} index The index of the bit we want to read.
3232
* @return {Number} 1 or 0, depending on the value set for that bit.
@@ -44,7 +44,7 @@ function readBit(bitsArray, index) {
4444
* @description
4545
* Stores a bit on the internal bits array.
4646
* We can only store 1s, so there is no need to pass the value to store.
47-
*
47+
*
4848
* @param {!Uint8Array} bitsArray An array containing all the bits for the filter, broken down by the byte.
4949
* @param {!Number} index The index of the bit we want to write.
5050
* @return {!boolean} true iff at least one bit was flipped, false otherwise (meaning the key was already stored in the
@@ -140,8 +140,8 @@ class BloomFilter {
140140
* tolerance would be too big to allocate an array for it.
141141
*/
142142
constructor(maxSize, maxTolerance = 0.01, seed = randomInt()) {
143-
let maxS = parseInt(maxSize, 10);
144-
let tol = parseFloat(maxTolerance, 10);
143+
let maxS = parseInt(maxSize, 10); //lgtm [js/superfluous-trailing-arguments]
144+
let tol = parseFloat(maxTolerance, 10); //lgtm [js/superfluous-trailing-arguments]
145145

146146
if (Number.isNaN(maxS) || maxSize <= 0) {
147147
throw new TypeError(ERROR_MSG_BLOOM_FILTER_CONSTRUCTOR_MAX_SIZE(maxSize));

JavaScript/src/disjointset/disjointset.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@ import { ERROR_MSG_INVALID_ARGUMENT } from '../common/errors.js';
33

44
const ERROR_MSG_UNION_FIND_CONSTRUCTOR_ILLEGAL_ARGUMENT = (val) => `Illegal argument for DisjointSet constructor: ${val}`;
55
const ERROR_MSG_UNION_FIND_CONSTRUCTOR_DUPLICATE_ELEMENT = (val) => `Duplicate element in initial set for DisjointSet constructor: ${val}`;
6-
const ERROR_MSG_FIND_ILLEGAL_ARGUMENT = (val) => `Illegal argument for method find: ${val}`;
76
const ERROR_MSG_FIND_NOT_IN_SET = (val) => `Argument ${val} for method find does not belong to this set`;
8-
const ERROR_MSG_ADD_ELEMENT = (val) => `Illegal argument for method add: ${val}`;
97

108
const _elements = new WeakMap();
119

JavaScript/src/disjointset/variants/disjointset_lists.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { ERROR_MSG_INVALID_ARGUMENT } from '../../common/errors.js';
44
const ERROR_MSG_UNION_FIND_CONSTRUCTOR_ILLEGAL_ARGUMENT = (val) => `Illegal argument for UnionFindLists constructor: ${val}`;
55
const ERROR_MSG_UNION_FIND_CONSTRUCTOR_DUPLICATE_ELEMENT = (val) => `Duplicate element in initial set for UnionFindLists constructor: ${val}`;
66
const ERROR_MSG_FIND_NOT_IN_SET = (val) => `Argument ${val} for method find does not belong to this set`;
7-
const ERROR_MSG_ADD_ELEMENT = (val) => `Illegal argument for method add: ${val}`;
87

98
const _partitionsMap = new WeakMap();
109

@@ -18,7 +17,7 @@ const _partitionsMap = new WeakMap();
1817
*
1918
* This class also support queries to find if two elements are in the same subset, through the disjoint method.
2019
* In addition a few utility methods to check the number of elements in the "universe" and to add new elements (as singleton subsets) are provided.
21-
*
20+
*
2221
* This implementation uses the simplest approach, with lists (Set) for the sets
2322
*/
2423
class UnionFindLists {

JavaScript/src/kd_tree/kd_tree.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -291,14 +291,14 @@ class Node {
291291
_point.set(this, points[0]);
292292
_size.set(this, 1);
293293
//Children are leaves
294-
_left.set(this, Node.Empty(dimensionality, depth + 1, this));
295-
_right.set(this, Node.Empty(dimensionality, depth + 1, this));
294+
_left.set(this, Node.Empty(dimensionality, depth + 1));
295+
_right.set(this, Node.Empty(dimensionality, depth + 1));
296296
break;
297297
default:
298298
let [med, left, right] = median(points, Node.keyByDim(this.dim));
299299
_point.set(this, med);
300-
_left.set(this, new Node(left, dimensionality, depth + 1, this));
301-
_right.set(this, new Node(right, dimensionality, depth + 1, this));
300+
_left.set(this, new Node(left, dimensionality, depth + 1));
301+
_right.set(this, new Node(right, dimensionality, depth + 1));
302302
_size.set(this, 1 + _left.get(this).size + _right.get(this).size);
303303
break;
304304
}
@@ -502,8 +502,8 @@ class Node {
502502
let added = false;
503503
if (this.isEmpty()) {
504504
_point.set(this, point);
505-
_left.set(this, Node.Empty(point.dimensionality, this.depth + 1, this));
506-
_right.set(this, Node.Empty(point.dimensionality, this.depth + 1, this));
505+
_left.set(this, Node.Empty(point.dimensionality, this.depth + 1));
506+
_right.set(this, Node.Empty(point.dimensionality, this.depth + 1));
507507
_size.set(this, 1);
508508
added = true;
509509
} else if (!this.point.equals(point)) {

JavaScript/src/strings/global_alignment.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ class GlobalAlignment {
129129

130130
const n = pattern.length + 1;
131131
const m = text.length + 1;
132-
let prevCol = new Array(n);
132+
let prevCol;
133133
let currentCol = new Array(n);
134134

135135
for (let i = 0; i < n; i++) {

JavaScript/src/utils/hash.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ const ERROR_MSG_HASH_SEED = (fname, val) => `Illegal parameter for ${fname}: see
2323
* @throws {TypeError(ERROR_MSG_HASH_SEED)} If seed is not a Number.
2424
*/
2525
export function murmurHash32(key, seed = 0) {
26-
'use strict';
27-
2826
if (typeof key !== 'string') {
2927
throw new TypeError(ERROR_MSG_HASH_KEY_TYPE('murmurHash32', key));
3028
}

Python/mlarocca/datastructures/huffman/huffman.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import collections
2-
from typing import Dict, List, Optional, Type
2+
from typing import Dict, List, Optional
33
from mlarocca.datastructures.heap.dway_heap import DWayHeap
44

55

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# **Algorithms and Data Structures in Action**
22

3+
[![Total alerts](https://img.shields.io/lgtm/alerts/g/mlarocca/AlgorithmsAndDataStructuresInAction.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/mlarocca/AlgorithmsAndDataStructuresInAction/alerts/)
4+
[![Language grade: JavaScript](https://img.shields.io/lgtm/grade/javascript/g/mlarocca/AlgorithmsAndDataStructuresInAction.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/mlarocca/AlgorithmsAndDataStructuresInAction/context:javascript)
5+
[![Language grade: Python](https://img.shields.io/lgtm/grade/python/g/mlarocca/AlgorithmsAndDataStructuresInAction.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/mlarocca/AlgorithmsAndDataStructuresInAction/context:python)
6+
37
This repository contains a collections of data structures and algorithms from the Manning book _Algorithms and Data Structures in Action_
48

59
You can buy the book on Manning's web site:

0 commit comments

Comments
 (0)