/** * @return the tree node at the specified index */ public Node<E> getTreeNode(int visibleIndex) { return data.get(visibleIndex, VISIBLE_NODES).get(); }
/** * @return <code>true</code> if this node shows up in the output * EventList, or <code>false</code> if it's a descendent of a * collapsed node. */ public boolean isVisible() { return (element.getColor() & VISIBLE_NODES) > 0; }
/** * @return the node that follows this one, or <code>null</code> if there * is no such node. */ private Node<E> next() { // TODO(jessewilson): this check prevents us from failing when the data // is inconstent. We don't like this check since it's broken that we need // to do it, instead we should be throwing IllegalStateException if(element == null) { return null; } Element<Node<E>> next = element.next(); return (next == null) ? null : next.get(); }
Element<Element> sortedNode = i.node(); Element<Element> unsortedNode = unsortedNodes[index]; sortedNode.set(unsortedNode); unsortedNode.set(sortedNode); int unsortedIndex = unsorted.indexOfNode(unsortedNode, ALL_COLORS); reorderMap[index] = newIndexToSortedIndex[unsortedIndex]; Element sortedNode = unsortedNode.get(); sortedNode.setSorted(Element.PENDING); updateNodes.add(sortedNode); previousValues.add(listChanges.getOldValue()); if(sortedNode.getSorted() != Element.PENDING) continue; Element upperBound = null; Element firstUnsortedNode = sortedNode; for(Element leftNeighbour = sortedNode.previous(); leftNeighbour != null; leftNeighbour = leftNeighbour.previous()) { if(leftNeighbour.getSorted() != Element.SORTED) { firstUnsortedNode = leftNeighbour; continue; for(Element rightNeighbour = sortedNode.next(); rightNeighbour != null; rightNeighbour = rightNeighbour.next()) { if(rightNeighbour.getSorted() != Element.SORTED) continue; upperBound = rightNeighbour; break; for(Element current = firstUnsortedNode; current != upperBound; current = current.next()) { if(upperBound != null && nodeComparator.compare(current.get(), upperBound.get()) > 0) {
/** * <p>We should consider removing the loop by only setting on removed elements. * * @param oldValue the previous value being replaced * @param newValue the new value * @param startIndex the first updated element, inclusive * @param endIndex the last index, exclusive */ public void targetUpdate(int startIndex, int endIndex, E oldValue, E newValue) { if(!initialCapacityKnown) ensureCapacity(endIndex); for(int i = startIndex; i < endIndex; i++) { int overallIndex = tree.convertIndexColor(i, TARGET_INDICES, ALL_INDICES); Element<E> standingChangeToIndex = tree.get(overallIndex, ALL_INDICES); if(horribleHackPreferMostRecentValue) { byte newColor = standingChangeToIndex.getColor() == INSERT ? INSERT : UPDATE; tree.set(overallIndex, ALL_INDICES, newColor, oldValue, 1); continue; } // don't bother updating an inserted element if(standingChangeToIndex.getColor() == INSERT) { continue; } // if we're updating an update, the original replaced value stands. if(standingChangeToIndex.getColor() == UPDATE) { oldValue = standingChangeToIndex.get(); } // apply the update to our change description tree.set(overallIndex, ALL_INDICES, UPDATE, oldValue, 1); } }
after.element.set(after);
Element<Element> sortedNode = i.node(); Element<Element> unsortedNode = unsortedNodes[index]; sortedNode.set(unsortedNode); unsortedNode.set(sortedNode); int unsortedIndex = unsorted.indexOfNode(unsortedNode, ALL_COLORS); reorderMap[index] = newIndexToSortedIndex[unsortedIndex]; Element sortedNode = unsortedNode.get(); sortedNode.setSorted(Element.PENDING); updateNodes.add(sortedNode); previousValues.add(listChanges.getOldValue()); if(sortedNode.getSorted() != Element.PENDING) continue; Element upperBound = null; Element firstUnsortedNode = sortedNode; for(Element leftNeighbour = sortedNode.previous(); leftNeighbour != null; leftNeighbour = leftNeighbour.previous()) { if(leftNeighbour.getSorted() != Element.SORTED) { firstUnsortedNode = leftNeighbour; continue; for(Element rightNeighbour = sortedNode.next(); rightNeighbour != null; rightNeighbour = rightNeighbour.next()) { if(rightNeighbour.getSorted() != Element.SORTED) continue; upperBound = rightNeighbour; break; for(Element current = firstUnsortedNode; current != upperBound; current = current.next()) { if(upperBound != null && nodeComparator.compare(current.get(), upperBound.get()) > 0) {
/** * <p>We should consider removing the loop by only setting on removed elements. * * @param oldValue the previous value being replaced * @param newValue the new value * @param startIndex the first updated element, inclusive * @param endIndex the last index, exclusive */ public void targetUpdate(int startIndex, int endIndex, E oldValue, E newValue) { if(!initialCapacityKnown) ensureCapacity(endIndex); for(int i = startIndex; i < endIndex; i++) { int overallIndex = tree.convertIndexColor(i, TARGET_INDICES, ALL_INDICES); Element<E> standingChangeToIndex = tree.get(overallIndex, ALL_INDICES); if(horribleHackPreferMostRecentValue) { byte newColor = standingChangeToIndex.getColor() == INSERT ? INSERT : UPDATE; tree.set(overallIndex, ALL_INDICES, newColor, oldValue, 1); continue; } // don't bother updating an inserted element if(standingChangeToIndex.getColor() == INSERT) { continue; } // if we're updating an update, the original replaced value stands. if(standingChangeToIndex.getColor() == UPDATE) { oldValue = standingChangeToIndex.get(); } // apply the update to our change description tree.set(overallIndex, ALL_INDICES, UPDATE, oldValue, 1); } }
after.element.set(after);
Element<Element> sortedNode = i.node(); Element<Element> unsortedNode = unsortedNodes[index]; sortedNode.set(unsortedNode); unsortedNode.set(sortedNode); int unsortedIndex = unsorted.indexOfNode(unsortedNode, ALL_COLORS); reorderMap[index] = newIndexToSortedIndex[unsortedIndex]; Element sortedNode = unsortedNode.get(); sortedNode.setSorted(Element.PENDING); updateNodes.add(sortedNode); previousValues.add(listChanges.getOldValue()); if(sortedNode.getSorted() != Element.PENDING) continue; Element upperBound = null; Element firstUnsortedNode = sortedNode; for(Element leftNeighbour = sortedNode.previous(); leftNeighbour != null; leftNeighbour = leftNeighbour.previous()) { if(leftNeighbour.getSorted() != Element.SORTED) { firstUnsortedNode = leftNeighbour; continue; for(Element rightNeighbour = sortedNode.next(); rightNeighbour != null; rightNeighbour = rightNeighbour.next()) { if(rightNeighbour.getSorted() != Element.SORTED) continue; upperBound = rightNeighbour; break; for(Element current = firstUnsortedNode; current != upperBound; current = current.next()) { if(upperBound != null && nodeComparator.compare(current.get(), upperBound.get()) > 0) {
/** {@inheritDoc} */ @Override public T0 get(int index) { return tree.get(index /*[ COLORED_START ]*/, colors /*[ COLORED_END ]*/).get(); }
/** * <p>We should consider removing the loop by only setting on removed elements. * * @param oldValue the previous value being replaced * @param newValue the new value * @param startIndex the first updated element, inclusive * @param endIndex the last index, exclusive */ public void targetUpdate(int startIndex, int endIndex, E oldValue, E newValue) { if(!initialCapacityKnown) ensureCapacity(endIndex); for(int i = startIndex; i < endIndex; i++) { int overallIndex = tree.convertIndexColor(i, TARGET_INDICES, ALL_INDICES); Element<E> standingChangeToIndex = tree.get(overallIndex, ALL_INDICES); if(horribleHackPreferMostRecentValue) { byte newColor = standingChangeToIndex.getColor() == INSERT ? INSERT : UPDATE; tree.set(overallIndex, ALL_INDICES, newColor, oldValue, 1); continue; } // don't bother updating an inserted element if(standingChangeToIndex.getColor() == INSERT) { continue; } // if we're updating an update, the original replaced value stands. if(standingChangeToIndex.getColor() == UPDATE) { oldValue = standingChangeToIndex.get(); } // apply the update to our change description tree.set(overallIndex, ALL_INDICES, UPDATE, oldValue, 1); } }
/** * @return the node that follows this one, or <code>null</code> if there * is no such node. */ private Node<E> next() { // TODO(jessewilson): this check prevents us from failing when the data // is inconstent. We don't like this check since it's broken that we need // to do it, instead we should be throwing IllegalStateException if(element == null) { return null; } Element<Node<E>> next = element.next(); return (next == null) ? null : next.get(); }
after.element.set(after);
/** * @return <code>true</code> if this node shows up in the output * EventList, or <code>false</code> if it's a descendent of a * collapsed node. */ public boolean isVisible() { return (element.getColor() & VISIBLE_NODES) > 0; }