Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd596e1d

Browse files
committed
Fix then > than typo.
1 parent8bd59b6 commitd596e1d

File tree

10 files changed

+38
-38
lines changed

10 files changed

+38
-38
lines changed

‎src/algorithms/search/binary-search/binarySearch.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export default function binarySearch(sortedArray, seekElement, comparatorCallbac
2222
}
2323

2424
// Decide which half to choose for seeking next: left or right one.
25-
if(comparator.lessThen(sortedArray[middleIndex],seekElement)){
25+
if(comparator.lessThan(sortedArray[middleIndex],seekElement)){
2626
// Go to the right half of the array.
2727
startIndex=middleIndex+1;
2828
}else{

‎src/algorithms/sorting/bubble-sort/BubbleSort.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export default class BubbleSort extends Sort {
1818
this.callbacks.visitingCallback(array[j]);
1919

2020
// Swap elements if they are in wrong order.
21-
if(this.comparator.lessThen(array[j+1],array[j])){
21+
if(this.comparator.lessThan(array[j+1],array[j])){
2222
consttmp=array[j+1];
2323
array[j+1]=array[j];
2424
array[j]=tmp;

‎src/algorithms/sorting/insertion-sort/InsertionSort.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export default class InsertionSort extends Sort {
1515
// If this is the case then swap that elements.
1616
while(
1717
array[currentIndex-1]&&
18-
this.comparator.lessThen(array[currentIndex],array[currentIndex-1])
18+
this.comparator.lessThan(array[currentIndex],array[currentIndex-1])
1919
){
2020
// Call visiting callback.
2121
this.callbacks.visitingCallback(array[currentIndex-1]);

‎src/algorithms/sorting/merge-sort/MergeSort.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export default class MergeSort extends Sort {
3131
letminimumElement=null;
3232

3333
// Find minimum element of two arrays.
34-
if(this.comparator.lessThenOrEqual(leftArray[0],rightArray[0])){
34+
if(this.comparator.lessThanOrEqual(leftArray[0],rightArray[0])){
3535
minimumElement=leftArray.shift();
3636
}else{
3737
minimumElement=rightArray.shift();

‎src/algorithms/sorting/quick-sort/QuickSort.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export default class QuickSort extends Sort {
2727

2828
if(this.comparator.equal(currentElement,pivotElement)){
2929
centerArray.push(currentElement);
30-
}elseif(this.comparator.lessThen(currentElement,pivotElement)){
30+
}elseif(this.comparator.lessThan(currentElement,pivotElement)){
3131
leftArray.push(currentElement);
3232
}else{
3333
rightArray.push(currentElement);

‎src/algorithms/sorting/selection-sort/SelectionSort.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export default class SelectionSort extends Sort {
1616
// Call visiting callback.
1717
this.callbacks.visitingCallback(array[j]);
1818

19-
if(this.comparator.lessThen(array[j],array[minIndex])){
19+
if(this.comparator.lessThan(array[j],array[minIndex])){
2020
minIndex=j;
2121
}
2222
}

‎src/algorithms/sorting/shell-sort/ShellSort.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export default class ShellSort extends Sort {
2020
this.callbacks.visitingCallback(array[currentIndex]);
2121

2222
// Compare and swap array elements if needed.
23-
if(this.comparator.lessThen(array[gapShiftedIndex],array[currentIndex])){
23+
if(this.comparator.lessThan(array[gapShiftedIndex],array[currentIndex])){
2424
consttmp=array[currentIndex];
2525
array[currentIndex]=array[gapShiftedIndex];
2626
array[gapShiftedIndex]=tmp;

‎src/data-structures/heap/MinHeap.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ export default class MinHeap {
167167
leftChild!==null&&
168168
(
169169
parentItem===null||
170-
this.compare.lessThen(parentItem,this.heapContainer[indexToRemove])
170+
this.compare.lessThan(parentItem,this.heapContainer[indexToRemove])
171171
)
172172
){
173173
this.heapifyDown(indexToRemove);
@@ -209,7 +209,7 @@ export default class MinHeap {
209209

210210
while(
211211
this.hasParent(currentIndex)&&
212-
this.compare.lessThen(this.heapContainer[currentIndex],this.parent(currentIndex))
212+
this.compare.lessThan(this.heapContainer[currentIndex],this.parent(currentIndex))
213213
){
214214
this.swap(currentIndex,this.getParentIndex(currentIndex));
215215
currentIndex=this.getParentIndex(currentIndex);
@@ -228,14 +228,14 @@ export default class MinHeap {
228228
while(this.hasLeftChild(currentIndex)){
229229
if(
230230
this.hasRightChild(currentIndex)&&
231-
this.compare.lessThen(this.rightChild(currentIndex),this.leftChild(currentIndex))
231+
this.compare.lessThan(this.rightChild(currentIndex),this.leftChild(currentIndex))
232232
){
233233
nextIndex=this.getRightChildIndex(currentIndex);
234234
}else{
235235
nextIndex=this.getLeftChildIndex(currentIndex);
236236
}
237237

238-
if(this.compare.lessThen(this.heapContainer[currentIndex],this.heapContainer[nextIndex])){
238+
if(this.compare.lessThan(this.heapContainer[currentIndex],this.heapContainer[nextIndex])){
239239
break;
240240
}
241241

‎src/utils/comparator/Comparator.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,20 @@ export default class Comparator {
2323
returnthis.compare(a,b)===0;
2424
}
2525

26-
lessThen(a,b){
26+
lessThan(a,b){
2727
returnthis.compare(a,b)<0;
2828
}
2929

30-
greaterThen(a,b){
30+
greaterThan(a,b){
3131
returnthis.compare(a,b)>0;
3232
}
3333

34-
lessThenOrEqual(a,b){
35-
returnthis.lessThen(a,b)||this.equal(a,b);
34+
lessThanOrEqual(a,b){
35+
returnthis.lessThan(a,b)||this.equal(a,b);
3636
}
3737

38-
greaterThenOrEqual(a,b){
39-
returnthis.greaterThen(a,b)||this.equal(a,b);
38+
greaterThanOrEqual(a,b){
39+
returnthis.greaterThan(a,b)||this.equal(a,b);
4040
}
4141

4242
reverse(){

‎src/utils/comparator/__test__/Comparator.test.js

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,19 @@ describe('Comparator', () => {
77
expect(comparator.equal(0,0)).toBeTruthy();
88
expect(comparator.equal(0,1)).toBeFalsy();
99
expect(comparator.equal('a','a')).toBeTruthy();
10-
expect(comparator.lessThen(1,2)).toBeTruthy();
11-
expect(comparator.lessThen(-1,2)).toBeTruthy();
12-
expect(comparator.lessThen('a','b')).toBeTruthy();
13-
expect(comparator.lessThen('a','ab')).toBeTruthy();
14-
expect(comparator.lessThen(10,2)).toBeFalsy();
15-
expect(comparator.lessThenOrEqual(10,2)).toBeFalsy();
16-
expect(comparator.lessThenOrEqual(1,1)).toBeTruthy();
17-
expect(comparator.lessThenOrEqual(0,0)).toBeTruthy();
18-
expect(comparator.greaterThen(0,0)).toBeFalsy();
19-
expect(comparator.greaterThen(10,0)).toBeTruthy();
20-
expect(comparator.greaterThenOrEqual(10,0)).toBeTruthy();
21-
expect(comparator.greaterThenOrEqual(10,10)).toBeTruthy();
22-
expect(comparator.greaterThenOrEqual(0,10)).toBeFalsy();
10+
expect(comparator.lessThan(1,2)).toBeTruthy();
11+
expect(comparator.lessThan(-1,2)).toBeTruthy();
12+
expect(comparator.lessThan('a','b')).toBeTruthy();
13+
expect(comparator.lessThan('a','ab')).toBeTruthy();
14+
expect(comparator.lessThan(10,2)).toBeFalsy();
15+
expect(comparator.lessThanOrEqual(10,2)).toBeFalsy();
16+
expect(comparator.lessThanOrEqual(1,1)).toBeTruthy();
17+
expect(comparator.lessThanOrEqual(0,0)).toBeTruthy();
18+
expect(comparator.greaterThan(0,0)).toBeFalsy();
19+
expect(comparator.greaterThan(10,0)).toBeTruthy();
20+
expect(comparator.greaterThanOrEqual(10,0)).toBeTruthy();
21+
expect(comparator.greaterThanOrEqual(10,10)).toBeTruthy();
22+
expect(comparator.greaterThanOrEqual(0,10)).toBeFalsy();
2323
});
2424

2525
it('should compare with custom comparator function',()=>{
@@ -33,18 +33,18 @@ describe('Comparator', () => {
3333

3434
expect(comparator.equal('a','b')).toBeTruthy();
3535
expect(comparator.equal('a','')).toBeFalsy();
36-
expect(comparator.lessThen('b','aa')).toBeTruthy();
37-
expect(comparator.greaterThenOrEqual('a','aa')).toBeFalsy();
38-
expect(comparator.greaterThenOrEqual('aa','a')).toBeTruthy();
39-
expect(comparator.greaterThenOrEqual('a','a')).toBeTruthy();
36+
expect(comparator.lessThan('b','aa')).toBeTruthy();
37+
expect(comparator.greaterThanOrEqual('a','aa')).toBeFalsy();
38+
expect(comparator.greaterThanOrEqual('aa','a')).toBeTruthy();
39+
expect(comparator.greaterThanOrEqual('a','a')).toBeTruthy();
4040

4141
comparator.reverse();
4242

4343
expect(comparator.equal('a','b')).toBeTruthy();
4444
expect(comparator.equal('a','')).toBeFalsy();
45-
expect(comparator.lessThen('b','aa')).toBeFalsy();
46-
expect(comparator.greaterThenOrEqual('a','aa')).toBeTruthy();
47-
expect(comparator.greaterThenOrEqual('aa','a')).toBeFalsy();
48-
expect(comparator.greaterThenOrEqual('a','a')).toBeTruthy();
45+
expect(comparator.lessThan('b','aa')).toBeFalsy();
46+
expect(comparator.greaterThanOrEqual('a','aa')).toBeTruthy();
47+
expect(comparator.greaterThanOrEqual('aa','a')).toBeFalsy();
48+
expect(comparator.greaterThanOrEqual('a','a')).toBeTruthy();
4949
});
5050
});

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp