File tree Expand file tree Collapse file tree 1 file changed +3
-1
lines changed
src/main/java/org/javimmutable/collections/btree_list Expand file tree Collapse file tree 1 file changed +3
-1
lines changed Original file line number Diff line number Diff line change 3636package org .javimmutable .collections .btree_list ;
3737
3838import org .javimmutable .collections .indexed .IndexedArray ;
39+ import org .javimmutable .collections .iterators .SingleValueIterator ;
3940
4041import javax .annotation .Nonnull ;
4142import java .util .Iterator ;
@@ -73,7 +74,7 @@ synchronized void rebuild(@Nonnull BtreeNode<T> root)
7374 {
7475 leafBuilder .clear ();
7576 size = 0 ;
76- Iterator <BtreeNode <T >> nodes = root .childIterator ();
77+ Iterator <BtreeNode <T >> nodes = root .depth () > 1 ? root . childIterator () : SingleValueIterator . of ( root );
7778 while (nodes .hasNext ()) {
7879 final BtreeNode <T > node = nodes .next ();
7980 if (nodes .hasNext ()) {
@@ -88,6 +89,7 @@ synchronized void rebuild(@Nonnull BtreeNode<T> root)
8889 size += node .valueCount ();
8990 }
9091 }
92+ assert size == root .valueCount ();
9193 }
9294
9395 synchronized BtreeNode <T > build ()
You can’t perform that action at this time.
0 commit comments