private static Entry createFromSorted(Iterator itr, int size, int level, int bottom) { level++; if (size == 0) return null; int leftSize = (size-1) >> 1; int rightSize = size-1-leftSize; Entry left = createFromSorted(itr, leftSize, level, bottom); Map.Entry orig = (Map.Entry)itr.next(); Entry right = createFromSorted(itr, rightSize, level, bottom); Entry e = new Entry(orig.getKey(), orig.getValue()); if (left != null) { e.left = left; left.parent = e; } if (right != null) { e.right = right; right.parent = e; } if (level == bottom) e.color = Entry.RED; return e; }
private static Entry createFromSorted(Iterator itr, int size, int level, int bottom) { level++; if (size == 0) return null; int leftSize = (size-1) >> 1; int rightSize = size-1-leftSize; Entry left = createFromSorted(itr, leftSize, level, bottom); Map.Entry orig = (Map.Entry)itr.next(); Entry right = createFromSorted(itr, rightSize, level, bottom); Entry e = new Entry(orig.getKey(), orig.getValue()); if (left != null) { e.left = left; left.parent = e; } if (right != null) { e.right = right; right.parent = e; } if (level == bottom) e.color = Entry.RED; return e; }
private static Entry createFromSorted(Iterator itr, int size, int level, int bottom) { level++; if (size == 0) return null; int leftSize = (size-1) >> 1; int rightSize = size-1-leftSize; Entry left = createFromSorted(itr, leftSize, level, bottom); Map.Entry orig = (Map.Entry)itr.next(); Entry right = createFromSorted(itr, rightSize, level, bottom); Entry e = new Entry(orig.getKey(), orig.getValue()); if (left != null) { e.left = left; left.parent = e; } if (right != null) { e.right = right; right.parent = e; } if (level == bottom) e.color = Entry.RED; return e; }
/** * Return a new Entry with same element and color as self, * but with null links. (Since it is never OK to have * multiple identical links in a RB tree.) */ protected Object clone() throws CloneNotSupportedException { Entry t = new Entry(key, element); t.color = color; return t; }
/** * Return a new Entry with same element and color as self, * but with null links. (Since it is never OK to have * multiple identical links in a RB tree.) */ protected Object clone() throws CloneNotSupportedException { Entry t = new Entry(key, element); t.color = color; return t; }
/** * Return a new Entry with same element and color as self, * but with null links. (Since it is never OK to have * multiple identical links in a RB tree.) */ protected Object clone() throws CloneNotSupportedException { Entry t = new Entry(key, element); t.color = color; return t; }