this.index = count1 - tree.indexOfNode(this.node, (byte)1);
/** * Create an iterator starting at the specified index. * * @param tree the tree to iterate * @param nextIndex the index to be returned after calling {@link #next next()}. * @param nextIndexColors the colors to interpret nextIndex in terms of */ public SimpleTreeIterator/**/(SimpleTree < T0> tree, int nextIndex, byte nextIndexColors) { this.tree = tree; // if the start is, we need to find the node in the tree if(nextIndex != 0) { int currentIndex = nextIndex - 1; this.node = ( SimpleNode < T0> )tree.get(currentIndex ); // find the counts count1 = currentIndex; // find out the index in the node this.index = count1 - tree.indexOfNode(this.node, (byte)1); // just start before the beginning of the tree } else { this.node = null; this.index = 0; } }
this.index = count1 - tree.indexOfNode(this.node, (byte)1);
/** {@inheritDoc} */ @Override protected int getSourceIndex(int mutationIndex) { Element sortedNode = sorted.get(mutationIndex); Element unsortedNode = (Element)sortedNode.get(); return unsorted.indexOfNode(unsortedNode, ALL_COLORS); }
/** {@inheritDoc} */ @Override protected int getSourceIndex(int mutationIndex) { Element sortedNode = sorted.get(mutationIndex); Element unsortedNode = (Element)sortedNode.get(); return unsorted.indexOfNode(unsortedNode, ALL_COLORS); }
/** {@inheritDoc} */ @Override protected int getSourceIndex(int mutationIndex) { Element sortedNode = sorted.get(mutationIndex); Element unsortedNode = (Element)sortedNode.get(); return unsorted.indexOfNode(unsortedNode, ALL_COLORS); }
/** * Inserts the specified unsorted node as the value in the sorted tree * and returns the sorted order. * * @return the sortIndex of the inserted object. */ private int insertByUnsortedNode(Element unsortedNode) { // add the object to the sorted set Element<Element> sortedNode = sorted.addInSortedOrder(ALL_COLORS, unsortedNode, 1); // assign the unsorted node the value of the sorted node unsortedNode.set(sortedNode); // return the sorted index return sorted.indexOfNode(sortedNode, ALL_COLORS); } /**
/** * Inserts the specified unsorted node as the value in the sorted tree * and returns the sorted order. * * @return the sortIndex of the inserted object. */ private int insertByUnsortedNode(Element unsortedNode) { // add the object to the sorted set Element<Element> sortedNode = sorted.addInSortedOrder(ALL_COLORS, unsortedNode, 1); // assign the unsorted node the value of the sorted node unsortedNode.set(sortedNode); // return the sorted index return sorted.indexOfNode(sortedNode, ALL_COLORS); } /**
/** * Deletes the node in the sorted tree based on the value of the specified * unsorted tree node. * * @return the sortIndex of the deleted object. */ private int deleteByUnsortedNode(Element unsortedNode) { // get the sorted node Element sortedNode = (Element)unsortedNode.get(); // look up the sorted index before removing the nodes int sortedIndex = sorted.indexOfNode(sortedNode, ALL_COLORS); // delete the sorted node from its tree sorted.remove(sortedIndex, 1); // return the sorted index return sortedIndex; }
/** * Inserts the specified unsorted node as the value in the sorted tree * and returns the sorted order. * * @return the sortIndex of the inserted object. */ private int insertByUnsortedNode(Element unsortedNode) { // add the object to the sorted set Element<Element> sortedNode = sorted.addInSortedOrder(ALL_COLORS, unsortedNode, 1); // assign the unsorted node the value of the sorted node unsortedNode.set(sortedNode); // return the sorted index return sorted.indexOfNode(sortedNode, ALL_COLORS); } /**
/** * Deletes the node in the sorted tree based on the value of the specified * unsorted tree node. * * @return the sortIndex of the deleted object. */ private int deleteByUnsortedNode(Element unsortedNode) { // get the sorted node Element sortedNode = (Element)unsortedNode.get(); // look up the sorted index before removing the nodes int sortedIndex = sorted.indexOfNode(sortedNode, ALL_COLORS); // delete the sorted node from its tree sorted.remove(sortedIndex, 1); // return the sorted index return sortedIndex; }
/** * Deletes the node in the sorted tree based on the value of the specified * unsorted tree node. * * @return the sortIndex of the deleted object. */ private int deleteByUnsortedNode(Element unsortedNode) { // get the sorted node Element sortedNode = (Element)unsortedNode.get(); // look up the sorted index before removing the nodes int sortedIndex = sorted.indexOfNode(sortedNode, ALL_COLORS); // delete the sorted node from its tree sorted.remove(sortedIndex, 1); // return the sorted index return sortedIndex; }
i.next(); Element<Element> unsortedNode = i.value(); int unsortedIndex = unsorted.indexOfNode(unsortedNode, ALL_COLORS); previousIndexToSortedIndex[unsortedIndex] = index; sortedNode.set(unsortedNode); unsortedNode.set(sortedNode); int unsortedIndex = unsorted.indexOfNode(unsortedNode, ALL_COLORS); reorderMap[index] = newIndexToSortedIndex[unsortedIndex]; indexChanged = indexChanged || (index != reorderMap[index]); Element<Element> sortedNode = updateNodes.get(i); assert(sortedNode.getSorted() != Element.PENDING); int originalIndex = sorted.indexOfNode(sortedNode, ALL_COLORS);
i.next(); Element<Element> unsortedNode = i.value(); int unsortedIndex = unsorted.indexOfNode(unsortedNode, ALL_COLORS); previousIndexToSortedIndex[unsortedIndex] = index; sortedNode.set(unsortedNode); unsortedNode.set(sortedNode); int unsortedIndex = unsorted.indexOfNode(unsortedNode, ALL_COLORS); reorderMap[index] = newIndexToSortedIndex[unsortedIndex]; indexChanged = indexChanged || (index != reorderMap[index]); Element<Element> sortedNode = updateNodes.get(i); assert(sortedNode.getSorted() != Element.PENDING); int originalIndex = sorted.indexOfNode(sortedNode, ALL_COLORS);
i.next(); Element<Element> unsortedNode = i.value(); int unsortedIndex = unsorted.indexOfNode(unsortedNode, ALL_COLORS); previousIndexToSortedIndex[unsortedIndex] = index; sortedNode.set(unsortedNode); unsortedNode.set(sortedNode); int unsortedIndex = unsorted.indexOfNode(unsortedNode, ALL_COLORS); reorderMap[index] = newIndexToSortedIndex[unsortedIndex]; indexChanged = indexChanged || (index != reorderMap[index]); Element<Element> sortedNode = updateNodes.get(i); assert(sortedNode.getSorted() != Element.PENDING); int originalIndex = sorted.indexOfNode(sortedNode, ALL_COLORS);
private void processInsert(final int changeIndex, E inserted, boolean notify) { // This is a bit clunky - to find the group for an element, I am // creating a new GroupList and looking for it in the tree. GroupLists // are considered equal if their matchers compare equal. GroupMatcher<E> matcher = factory.createGroupMatcher(inserted); GroupList newGroup = new GroupList(matcher); int groupIndex = groupLists.indexOfValue(newGroup, true, false, (byte) 1); if (groupIndex >= 0) { insertHelper(changeIndex, groupIndex); if (notify) { GroupList groupingList = groupLists.get(groupIndex).get(); // an insert on the existing list groupingList.getListEventAssembler().elementInserted( groupingList.barcode.getBlackIndex(changeIndex), inserted); // an update on the grouping list updates.elementUpdated(groupIndex, groupingList, groupingList); } } else { Element<GroupList> newList = groupLists.addInSortedOrder((byte) 1, newGroup, 1); groupIndex = groupLists.indexOfNode(newList, (byte) 1); insertHelper(changeIndex, groupIndex); if (notify) { // begin event so later inserts, updates, deletes will work newGroup.getListEventAssembler().beginEvent(); // an update on the grouping list updates.elementInserted(groupIndex, newGroup); } } }
Element unsortedNode = (Element)oldSortedNode.get(); Element newSortedNode = (Element)unsortedNode.get(); int newSortedIndex = sorted.indexOfNode(newSortedNode, ALL_COLORS); reorderMap[newSortedIndex] = oldSortedIndex;
Element unsortedNode = (Element)oldSortedNode.get(); Element newSortedNode = (Element)unsortedNode.get(); int newSortedIndex = sorted.indexOfNode(newSortedNode, ALL_COLORS); reorderMap[newSortedIndex] = oldSortedIndex;
Element unsortedNode = (Element)oldSortedNode.get(); Element newSortedNode = (Element)unsortedNode.get(); int newSortedIndex = sorted.indexOfNode(newSortedNode, ALL_COLORS); reorderMap[newSortedIndex] = oldSortedIndex;