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 Entry getMatchingEntry(Object o) { if (!(o instanceof Map.Entry)) return null; Map.Entry e = (Map.Entry)o; Entry found = TreeMap.this.getEntry(e.getKey()); return (found != null && eq(found.getValue(), e.getValue())) ? found : null; }
public Object put(Object key, Object value) { if (root == null) { root = new Entry(key, value); size++; modCount++; Entry t = root; for (;;) { int diff = compare(key, t.getKey(), comparator); if (diff == 0) return t.setValue(value); else if (diff <= 0) { if (t.left != null) t = t.left; size++; modCount++; Entry e = new Entry(key, value); e.parent = t; t.left = e; size++; modCount++; Entry e = new Entry(key, value); e.parent = t; t.right = e;
public Object put(Object key, Object value) { if (root == null) { root = new Entry(key, value); size++; modCount++; Entry t = root; for (;;) { int diff = compare(key, t.getKey(), comparator); if (diff == 0) return t.setValue(value); else if (diff <= 0) { if (t.left != null) t = t.left; size++; modCount++; Entry e = new Entry(key, value); e.parent = t; t.left = e; size++; modCount++; Entry e = new Entry(key, value); e.parent = t; t.right = e;
public Object put(Object key, Object value) { if (root == null) { root = new Entry(key, value); size++; modCount++; Entry t = root; for (;;) { int diff = compare(key, t.getKey(), comparator); if (diff == 0) return t.setValue(value); else if (diff <= 0) { if (t.left != null) t = t.left; size++; modCount++; Entry e = new Entry(key, value); e.parent = t; t.left = e; size++; modCount++; Entry e = new Entry(key, value); e.parent = t; t.right = 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; }
private TreeMap.Entry getMatchingSubEntry(Object o) { if (!(o instanceof Map.Entry)) return null; Map.Entry e = (Map.Entry)o; Object key = e.getKey(); if (!inRange(key)) return null; TreeMap.Entry found = getEntry(key); return (found != null && eq(found.getValue(), e.getValue())) ? found : null; }
public Object remove(Object key) { Entry e = getEntry(key); if (e == null) return null; Object old = e.getValue(); delete(e); return old; }
private TreeMap.Entry getMatchingSubEntry(Object o) { if (!(o instanceof Map.Entry)) return null; Map.Entry e = (Map.Entry)o; Object key = e.getKey(); if (!inRange(key)) return null; TreeMap.Entry found = getEntry(key); return (found != null && eq(found.getValue(), e.getValue())) ? found : null; }
public Object remove(Object key) { Entry e = getEntry(key); if (e == null) return null; Object old = e.getValue(); delete(e); return old; }
private Entry getMatchingEntry(Object o) { if (!(o instanceof Map.Entry)) return null; Map.Entry e = (Map.Entry)o; Entry found = TreeMap.this.getEntry(e.getKey()); return (found != null && eq(found.getValue(), e.getValue())) ? found : null; }
/** * {@inheritDoc} */ public Object get(Object key) { Entry entry = getEntry(key); return (entry == null) ? null : entry.getValue(); }
private Entry getMatchingEntry(Object o) { if (!(o instanceof Map.Entry)) return null; Map.Entry e = (Map.Entry)o; Entry found = TreeMap.this.getEntry(e.getKey()); return (found != null && eq(found.getValue(), e.getValue())) ? found : null; }
/** * {@inheritDoc} */ public Object get(Object key) { Entry entry = getEntry(key); return (entry == null) ? null : entry.getValue(); }
/** * 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; }
public Object remove(Object key) { Entry e = getEntry(key); if (e == null) return null; Object old = e.getValue(); delete(e); return old; }
/** * 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; }
/** * {@inheritDoc} */ public Object get(Object key) { Entry entry = getEntry(key); return (entry == null) ? null : entry.getValue(); }