Skip to content

Commit c39b3fe

Browse files
committed
Add values function to Collection interface
1 parent caa9d26 commit c39b3fe

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

src/data/collections/mutable/Collection.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ type CollectionConfig = {
1414
interface Collection<T> {
1515
has(element: T): boolean;
1616
hasByHash(hash: Hash): boolean;
17+
values(): IterableIterator<T>;
1718
}
1819

1920
// WARNING: CausalCollection extends this class and uses some of its fields directly,

src/data/collections/mutable/MutableArray.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,10 @@ class MutableArray<T> extends BaseCollection<T> implements Collection<T> {
338338
return Array.from(this._hashes);
339339
}
340340

341+
values(): IterableIterator<T> {
342+
return this.contents().values();
343+
}
344+
341345
lookup(idx: number): T {
342346
this.rebuild();
343347
return this._contents[idx];

src/data/collections/mutable/MutableSet.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { HashReference } from 'data/model/immutable/HashReference';
77
import { Logger, LogLevel } from 'util/logging';
88
import { MultiMap } from 'util/multimap';
99
import { ClassRegistry } from 'data/model';
10-
import { BaseCollection, CollectionConfig, CollectionOp } from './Collection';
10+
import { BaseCollection, Collection, CollectionConfig, CollectionOp } from './Collection';
1111

1212
type ElmtHash = Hash;
1313

@@ -164,7 +164,7 @@ class DeleteOp<T> extends CollectionOp<T> {
164164

165165
}
166166

167-
class MutableSet<T> extends BaseCollection<T> {
167+
class MutableSet<T> extends BaseCollection<T> implements Collection<T> {
168168

169169
static className = 'hss/v0/MutableSet';
170170
static opClasses = [AddOp.className, DeleteOp.className];

0 commit comments

Comments
 (0)