/** {@inheritDoc} */ @Override public void add(int index, T0 element) { tree.add(index, element, 1); }
/** {@inheritDoc} */ @Override public void add(int index, T0 element) { tree.add(index, element, 1); }
/** {@inheritDoc} */ @Override public void add(int index, T0 element) { tree.add(index, element, 1); }
/** * Replace all values at the specified index with the specified new value. * * <p>Currently this uses a naive implementation of remove then add. If * it proves desirable, it may be worthwhile to optimize this implementation * with one that performs the remove and insert simultaneously, to save * on tree navigation. * * @return the element that was updated. This is non-null unless the size * parameter is 0, in which case the result is always <code>null</code>. */ public Element<T0> set(int index, T0 value, int size) { remove(index, size); return add(index, value, size); }
/** * Replace all values at the specified index with the specified new value. * * <p>Currently this uses a naive implementation of remove then add. If * it proves desirable, it may be worthwhile to optimize this implementation * with one that performs the remove and insert simultaneously, to save * on tree navigation. * * @return the element that was updated. This is non-null unless the size * parameter is 0, in which case the result is always <code>null</code>. */ public Element<T0> set(int index, T0 value, int size) { remove(index, size); return add(index, value, size); }
/** * Replace all values at the specified index with the specified new value. * * <p>Currently this uses a naive implementation of remove then add. If * it proves desirable, it may be worthwhile to optimize this implementation * with one that performs the remove and insert simultaneously, to save * on tree navigation. * * @return the element that was updated. This is non-null unless the size * parameter is 0, in which case the result is always <code>null</code>. */ public Element<T0> set(int index, T0 value, int size) { remove(index, size); return add(index, value, size); }
/** * Helper for {@link #listChanged(ListEvent)} when inserting. */ private void handleInsert(int parentIndex) { // find the index of the black node with that index int absoluteIndex = getAbsoluteIndex(parentIndex); // find the size of the new node and add it to the total S parent = source.get(parentIndex); List<E> children = model.getChildren(parent); // update the list of child lists Element<ChildElement<E>> node = childElements.add(parentIndex, EMPTY_CHILD_ELEMENT, 1); node.set(createChildElementForList(children, node)); // update the barcode barcode.addBlack(absoluteIndex, 1); if(!children.isEmpty()) barcode.addWhite(absoluteIndex + 1, children.size()); // add events int childIndex = absoluteIndex - parentIndex; for(int i = 0; i < children.size(); i++) { E element = children.get(i); updates.elementInserted(childIndex, element); } }
/** * Helper for {@link #listChanged(ListEvent)} when inserting. */ private void handleInsert(int parentIndex) { // find the index of the black node with that index int absoluteIndex = getAbsoluteIndex(parentIndex); // find the size of the new node and add it to the total S parent = source.get(parentIndex); List<E> children = model.getChildren(parent); // update the list of child lists Element<ChildElement<E>> node = childElements.add(parentIndex, EMPTY_CHILD_ELEMENT, 1); node.set(createChildElementForList(children, node)); // update the barcode barcode.addBlack(absoluteIndex, 1); if(!children.isEmpty()) barcode.addWhite(absoluteIndex + 1, children.size()); // add events int childIndex = absoluteIndex - parentIndex; for(int i = 0; i < children.size(); i++) { E element = children.get(i); updates.elementInserted(childIndex, element); } }
/** * Helper for {@link #listChanged(ListEvent)} when inserting. */ private void handleInsert(int parentIndex) { // find the index of the black node with that index int absoluteIndex = getAbsoluteIndex(parentIndex); // find the size of the new node and add it to the total S parent = source.get(parentIndex); List<E> children = model.getChildren(parent); // update the list of child lists Element<ChildElement<E>> node = childElements.add(parentIndex, EMPTY_CHILD_ELEMENT, 1); node.set(createChildElementForList(children, node)); // update the barcode barcode.addBlack(absoluteIndex, 1); if(!children.isEmpty()) barcode.addWhite(absoluteIndex + 1, children.size()); // add events int childIndex = absoluteIndex - parentIndex; for(int i = 0; i < children.size(); i++) { E element = children.get(i); updates.elementInserted(childIndex, element); } }
/** * Create a {@link CollectionList} with its contents being the children of * the elements in the specified source {@link EventList}. * * @param source an EventList of Objects from each of which the * <code>model</code> can extract child elements * @param model the logic for extracting children from each * <code>source</code> element */ public CollectionList(EventList<S> source, Model<S, E> model) { super(source); if(model == null) throw new IllegalArgumentException("model cannot be null"); this.model = model; // sync the current size and indexes for(int i = 0, n = source.size(); i < n; i++) { List<E> children = model.getChildren(source.get(i)); // update the list of child lists Element<ChildElement<E>> node = childElements.add(i, EMPTY_CHILD_ELEMENT, 1); node.set(createChildElementForList(children, node)); // update the barcode barcode.addBlack(barcode.size(), 1); if(!children.isEmpty()) barcode.addWhite(barcode.size(), children.size()); } // listen for changes source.addListEventListener(this); }
/** * Create a {@link CollectionList} with its contents being the children of * the elements in the specified source {@link EventList}. * * @param source an EventList of Objects from each of which the * <code>model</code> can extract child elements * @param model the logic for extracting children from each * <code>source</code> element */ public CollectionList(EventList<S> source, Model<S, E> model) { super(source); if(model == null) throw new IllegalArgumentException("model cannot be null"); this.model = model; // sync the current size and indexes for(int i = 0, n = source.size(); i < n; i++) { List<E> children = model.getChildren(source.get(i)); // update the list of child lists Element<ChildElement<E>> node = childElements.add(i, EMPTY_CHILD_ELEMENT, 1); node.set(createChildElementForList(children, node)); // update the barcode barcode.addBlack(barcode.size(), 1); if(!children.isEmpty()) barcode.addWhite(barcode.size(), children.size()); } // listen for changes source.addListEventListener(this); }
/** * Create a {@link CollectionList} with its contents being the children of * the elements in the specified source {@link EventList}. * * @param source an EventList of Objects from each of which the * <code>model</code> can extract child elements * @param model the logic for extracting children from each * <code>source</code> element */ public CollectionList(EventList<S> source, Model<S, E> model) { super(source); if(model == null) throw new IllegalArgumentException("model cannot be null"); this.model = model; // sync the current size and indexes for(int i = 0, n = source.size(); i < n; i++) { List<E> children = model.getChildren(source.get(i)); // update the list of child lists Element<ChildElement<E>> node = childElements.add(i, EMPTY_CHILD_ELEMENT, 1); node.set(createChildElementForList(children, node)); // update the barcode barcode.addBlack(barcode.size(), 1); if(!children.isEmpty()) barcode.addWhite(barcode.size(), children.size()); } // listen for changes source.addListEventListener(this); }
Element<Element> unsortedNode = unsorted.add(unsortedIndex, EMPTY_ELEMENT, 1); insertNodes.addLast(unsortedNode);
/** * Statically build the separators data structures. */ private void rebuildSeparators() { // clear the initial state of these separators insertedSeparators = new Barcode(); separators = new SimpleTree<GroupSeparator>(); // prepare the separator list insertedSeparators.add(0, SOURCE_ELEMENT, source.size()); for(BarcodeIterator i = grouper.getBarcode().iterator(); i.hasNextColour(Grouper.UNIQUE); ) { i.nextColour(Grouper.UNIQUE); int groupIndex = i.getColourIndex(Grouper.UNIQUE); int sourceIndex = i.getIndex(); insertedSeparators.add(groupIndex + sourceIndex, SEPARATOR, 1); Element<GroupSeparator> node = separators.add(groupIndex, new GroupSeparator(), 1); node.get().setNode(node); node.get().applyLimit(defaultLimit, false); } // update the cached values in all separators for(int i = 0; i < separators.size(); i++) { separators.get(i).get().updateCachedValues(); } }
/** * Statically build the separators data structures. */ private void rebuildSeparators() { // clear the initial state of these separators insertedSeparators = new Barcode(); separators = new SimpleTree<>(); // prepare the separator list insertedSeparators.add(0, SOURCE_ELEMENT, source.size()); for(BarcodeIterator i = grouper.getBarcode().iterator(); i.hasNextColour(Grouper.UNIQUE); ) { i.nextColour(Grouper.UNIQUE); int groupIndex = i.getColourIndex(Grouper.UNIQUE); int sourceIndex = i.getIndex(); insertedSeparators.add(groupIndex + sourceIndex, SEPARATOR, 1); Element<GroupSeparator> node = separators.add(groupIndex, new GroupSeparator(), 1); node.get().setNode(node); node.get().applyLimit(defaultLimit, false); } // update the cached values in all separators for(int i = 0; i < separators.size(); i++) { separators.get(i).get().updateCachedValues(); } }
/** * Statically build the separators data structures. */ private void rebuildSeparators() { // clear the initial state of these separators insertedSeparators = new Barcode(); separators = new SimpleTree<GroupSeparator>(); // prepare the separator list insertedSeparators.add(0, SOURCE_ELEMENT, source.size()); for(BarcodeIterator i = grouper.getBarcode().iterator(); i.hasNextColour(Grouper.UNIQUE); ) { i.nextColour(Grouper.UNIQUE); int groupIndex = i.getColourIndex(Grouper.UNIQUE); int sourceIndex = i.getIndex(); insertedSeparators.add(groupIndex + sourceIndex, SEPARATOR, 1); Element<GroupSeparator> node = separators.add(groupIndex, new GroupSeparator(), 1); node.get().setNode(node); node.get().applyLimit(defaultLimit, false); } // update the cached values in all separators for(int i = 0; i < separators.size(); i++) { separators.get(i).get().updateCachedValues(); } }
/** * Statically build the separators data structures. */ private void rebuildSeparators() { // clear the initial state of these separators insertedSeparators = new Barcode(); separators = new SimpleTree<GroupSeparator>(); // prepare the separator list insertedSeparators.add(0, SOURCE_ELEMENT, source.size()); for(BarcodeIterator i = grouper.getBarcode().iterator(); i.hasNextColour(Grouper.UNIQUE); ) { i.nextColour(Grouper.UNIQUE); int groupIndex = i.getColourIndex(Grouper.UNIQUE); int sourceIndex = i.getIndex(); insertedSeparators.add(groupIndex + sourceIndex, SEPARATOR, 1); Element<GroupSeparator> node = separators.add(groupIndex, new GroupSeparator(), 1); node.get().setNode(node); node.get().applyLimit(defaultLimit, false); } // update the cached values in all separators for(int i = 0; i < separators.size(); i++) { separators.get(i).get().updateCachedValues(); } }
Element unsortedNode = unsorted.add(i, EMPTY_ELEMENT, 1); insertByUnsortedNode(unsortedNode);
Element unsortedNode = unsorted.add(i, EMPTY_ELEMENT, 1); insertByUnsortedNode(unsortedNode);
Element unsortedNode = unsorted.add(i, EMPTY_ELEMENT, 1); insertByUnsortedNode(unsortedNode);