File tree Expand file tree Collapse file tree 4 files changed +0
-67
lines changed Expand file tree Collapse file tree 4 files changed +0
-67
lines changed Original file line number Diff line number Diff line change @@ -78,20 +78,6 @@ export class DocumentSet {
78
78
return this . sortedSet . isEmpty ( ) ;
79
79
}
80
80
81
- /**
82
- * Returns previous document or null if it's a first doc.
83
- *
84
- * @param key A key that MUST be present in the DocumentSet.
85
- */
86
- prevDoc ( key : DocumentKey ) : Document | null {
87
- assert (
88
- this . has ( key ) ,
89
- 'Trying to get a previous document to non-existing key: ' + key
90
- ) ;
91
- const doc = this . keyedMap . get ( key ) ;
92
- return this . sortedSet . getPredecessorKey ( doc ! ) ;
93
- }
94
-
95
81
/**
96
82
* Returns the index of the provided key in the document set, or -1 if the
97
83
* document key is not present in the set;
Original file line number Diff line number Diff line change @@ -87,37 +87,6 @@ export class SortedMap<K, V> {
87
87
return null ;
88
88
}
89
89
90
- // Returns the key of the item *before* the specified key, or null if key is
91
- // the first item.
92
- getPredecessorKey ( key : K ) : K | null {
93
- let node = this . root ;
94
- let rightParent : LLRBNode < K , V > | LLRBEmptyNode < K , V > | null = null ;
95
- while ( ! node . isEmpty ( ) ) {
96
- const cmp = this . comparator ( key , node . key ) ;
97
- if ( cmp === 0 ) {
98
- if ( ! node . left . isEmpty ( ) ) {
99
- node = node . left ;
100
- while ( ! node . right . isEmpty ( ) ) node = node . right ;
101
- return node . key ;
102
- } else if ( rightParent ) {
103
- return rightParent . key ;
104
- } else {
105
- return null ; // first item.
106
- }
107
- } else if ( cmp < 0 ) {
108
- node = node . left ;
109
- } else if ( cmp > 0 ) {
110
- rightParent = node ;
111
- node = node . right ;
112
- }
113
- }
114
-
115
- throw fail (
116
- 'Attempted to find predecessor key for a nonexistent key.' +
117
- ' What gives?'
118
- ) ;
119
- }
120
-
121
90
// Returns the index of the element in this sorted map, or -1 if it doesn't
122
91
// exist.
123
92
indexOf ( key : K ) : number {
Original file line number Diff line number Diff line change @@ -50,10 +50,6 @@ describe('DocumentSet', () => {
50
50
const results : Document [ ] = [ ] ;
51
51
set . forEach ( ( d : Document ) => results . push ( d ) ) ;
52
52
expect ( results ) . to . deep . equal ( [ d3 , d1 , d2 ] ) ;
53
-
54
- expect ( set . prevDoc ( d3 . key ) ) . to . deep . equal ( null ) ;
55
- expect ( set . prevDoc ( d1 . key ) ) . to . deep . equal ( d3 ) ;
56
- expect ( set . prevDoc ( d2 . key ) ) . to . deep . equal ( d1 ) ;
57
53
} ) ;
58
54
59
55
it ( 'adds and deletes elements' , ( ) => {
@@ -90,7 +86,6 @@ describe('DocumentSet', () => {
90
86
const set = documentSet ( comp , doc1 , doc2 ) ;
91
87
expect ( set . has ( doc1 . key ) ) . to . equal ( true ) ;
92
88
expect ( set . has ( doc2 . key ) ) . to . equal ( true ) ;
93
- expect ( set . prevDoc ( doc2 . key ) ) . to . equal ( doc1 ) ;
94
89
} ) ;
95
90
96
91
it ( 'equals to other document set with the same elements and order' , ( ) => {
Original file line number Diff line number Diff line change @@ -412,23 +412,6 @@ describe('SortedMap Tests', () => {
412
412
expect ( expected ) . to . equal ( 10 ) ;
413
413
} ) ;
414
414
415
- it ( 'SortedMap.getPredecessorKey works.' , ( ) => {
416
- const map = new SortedMap ( primitiveComparator )
417
- . insert ( 1 , 1 )
418
- . insert ( 50 , 50 )
419
- . insert ( 3 , 3 )
420
- . insert ( 4 , 4 )
421
- . insert ( 7 , 7 )
422
- . insert ( 9 , 9 ) ;
423
-
424
- expect ( map . getPredecessorKey ( 1 ) ) . to . equal ( null ) ;
425
- expect ( map . getPredecessorKey ( 3 ) ) . to . equal ( 1 ) ;
426
- expect ( map . getPredecessorKey ( 4 ) ) . to . equal ( 3 ) ;
427
- expect ( map . getPredecessorKey ( 7 ) ) . to . equal ( 4 ) ;
428
- expect ( map . getPredecessorKey ( 9 ) ) . to . equal ( 7 ) ;
429
- expect ( map . getPredecessorKey ( 50 ) ) . to . equal ( 9 ) ;
430
- } ) ;
431
-
432
415
it ( 'SortedMap.indexOf returns index.' , ( ) => {
433
416
const map = new SortedMap ( primitiveComparator )
434
417
. insert ( 1 , 1 )
You can’t perform that action at this time.
0 commit comments