Skip to content

Commit e6e9e40

Browse files
committed
deleteByKey
1 parent 372258d commit e6e9e40

File tree

6 files changed

+22
-22
lines changed

6 files changed

+22
-22
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ An implementation of the round robin as a data structure. Two strategies are imp
1515
* [count()](#count)
1616
* [next()](#next)
1717
* [completedRounds()](#completedrounds)
18-
* [delete(key)](#deletekey)
18+
* [deleteByKey(key)](#deletebykeykey)
1919
* [reset()](#reset)
2020
* [clear()](#clear)
2121
* [Build](#build)
@@ -199,8 +199,8 @@ console.log(sequentialTable.completedRounds()); // 1
199199
console.log(randomTable.completedRounds()); // 1
200200
```
201201

202-
### delete(key)
203-
deletes an item from the table by its key.
202+
### deleteByKey(key)
203+
deletes an item by its key from the table.
204204

205205
<table>
206206
<tr>

src/RandomRoundRobin.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,12 @@ class RandomRoundRobin extends RoundRobin {
4141
}
4242

4343
/**
44-
* Deletes an item with its key from the table
44+
* Deletes an item by its key from the table
4545
* @public
4646
* @param {number} key
4747
* @return {boolean}
4848
*/
49-
delete(key) {
49+
deleteByKey(key) {
5050
if (!this._items.has(key)) {
5151
return false;
5252
}

src/RoundRobin.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export interface RoundRobinItem<T> {
66
export class RoundRobin<T> {
77
constructor(values?: T[]);
88
add(value: T): RoundRobinItem<T>;
9-
delete(key: number): boolean;
9+
deleteByKey(key: number): boolean;
1010
next(): RoundRobinItem<T>;
1111
count(): number;
1212
completedRounds(): number;

src/SequentialRoundRobin.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,12 @@ class SequentialRoundRobin extends RoundRobin {
4444
}
4545

4646
/**
47-
* Deletes an item from the table
47+
* Deletes an item by its key from the table
4848
* @public
4949
* @param {number} key
5050
* @return {boolean}
5151
*/
52-
delete(key) {
52+
deleteByKey(key) {
5353
if (!this._itemNodes.has(key)) {
5454
return false;
5555
}

test/RandomRoundRobin.test.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ const { RandomRoundRobin } = require('../src/RandomRoundRobin');
44
describe('RandomRoundRobin tests', () => {
55
const round = new RandomRoundRobin(['item 1', 'item 2']);
66

7-
describe('.add', () => {
7+
describe('add', () => {
88
it('adds items to the round', () => {
99
expect(round.add('item 3')).to.deep.equal({ key: 2, value: 'item 3' });
1010
expect(round.add('item 4')).to.deep.equal({ key: 3, value: 'item 4' });
1111
expect(round.count()).to.equal(4);
1212
});
1313
});
1414

15-
describe('.next', () => {
15+
describe('next', () => {
1616
it('gets the next item in the round', () => {
1717
const items = [
1818
round.next(),
@@ -25,10 +25,10 @@ describe('RandomRoundRobin tests', () => {
2525
});
2626
});
2727

28-
describe('.delete', () => {
28+
describe('deleteByKey', () => {
2929
it('removes items from the round', () => {
30-
round.delete(0);
31-
round.delete(2);
30+
round.deleteByKey(0);
31+
round.deleteByKey(2);
3232
expect(round.count()).to.equal(2);
3333

3434
const items = [
@@ -40,14 +40,14 @@ describe('RandomRoundRobin tests', () => {
4040
});
4141
});
4242

43-
describe('.reset', () => {
43+
describe('reset', () => {
4444
it('reset the round', () => {
4545
round.reset();
4646
expect(round.count()).to.equal(2);
4747
});
4848
});
4949

50-
describe('.clear', () => {
50+
describe('clear', () => {
5151
it('clears the round', () => {
5252
round.clear();
5353
expect(round.count()).to.equal(0);

test/SequentialRoundRobin.test.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ const { SequentialRoundRobin } = require('../src/SequentialRoundRobin');
44
describe('SequentialRoundRobin tests', () => {
55
const round = new SequentialRoundRobin(['item 1', 'item 2']);
66

7-
describe('.add', () => {
7+
describe('add', () => {
88
it('adds items to the round', () => {
99
expect(round.add('item 3')).to.deep.equal({ key: 2, value: 'item 3' });
1010
expect(round.add('item 4')).to.deep.equal({ key: 3, value: 'item 4' });
1111
expect(round.count()).to.equal(4);
1212
});
1313
});
1414

15-
describe('.next', () => {
15+
describe('next', () => {
1616
it('gets the next item in the round', () => {
1717
const next1 = round.next();
1818
expect(next1.key).to.equal(0);
@@ -37,10 +37,10 @@ describe('SequentialRoundRobin tests', () => {
3737
});
3838
});
3939

40-
describe('.delete', () => {
40+
describe('delete', () => {
4141
it('removes items from the round', () => {
42-
round.delete(1);
43-
round.delete(3);
42+
round.deleteByKey(1);
43+
round.deleteByKey(3);
4444
expect(round.count()).to.equal(2);
4545

4646
const next1 = round.next();
@@ -66,7 +66,7 @@ describe('SequentialRoundRobin tests', () => {
6666
});
6767
});
6868

69-
describe('.reset', () => {
69+
describe('reset', () => {
7070
it('reset the round', () => {
7171
round.reset();
7272
expect(round.count()).to.equal(2);
@@ -81,7 +81,7 @@ describe('SequentialRoundRobin tests', () => {
8181
});
8282
});
8383

84-
describe('.clear', () => {
84+
describe('clear', () => {
8585
it('clears the round', () => {
8686
round.clear();
8787
expect(round.count()).to.equal(0);

0 commit comments

Comments
 (0)