/** {@inheritDoc} */ @Override public T0 set(int index, T0 element) { T0 replaced = get(index); tree.set(index, colors, color, element, 1); return replaced; }
/** {@inheritDoc} */ @Override public T0 set(int index, T0 element) { T0 replaced = get(index); tree.set(index, colors, color, element, 1); return replaced; }
/** {@inheritDoc} */ @Override public T0 set(int index, T0 element) { T0 replaced = get(index); tree.set(index, colors, color, element, 1); return replaced; }
public void sourceRevert(int sourceIndex) { tree.set(sourceIndex, SOURCE_INDICES, NO_CHANGE, ListEvent.<E>unknownValue(), 1); }
public void sourceRevert(int sourceIndex) { tree.set(sourceIndex, SOURCE_INDICES, NO_CHANGE, ListEvent.<E>unknownValue(), 1); }
public void sourceRevert(int sourceIndex) { tree.set(sourceIndex, SOURCE_INDICES, NO_CHANGE, ListEvent.<E>unknownValue(), 1); }
/** * <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); } }
/** * <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); } }
/** * <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); } }
/** * <p>We should consider removing the loop from this method by counting * the inserted elements between startIndex and endIndex, removing those, * then removing everything else... * * @param startIndex the index of the first element to remove * @param endIndex the last index, exclusive * @param value the removed value */ public void targetDelete(int startIndex, int endIndex, E value) { if(!initialCapacityKnown) ensureCapacity(endIndex); for(int i = startIndex; i < endIndex; i++) { if(startIndex > 0 && startIndex > tree.size(TARGET_INDICES)) { throw new IllegalArgumentException(); } int overallIndex = tree.convertIndexColor(startIndex, TARGET_INDICES, ALL_INDICES); Element<E> standingChangeToIndex = tree.get(overallIndex, ALL_INDICES); // if we're deleting an insert, remove that insert if(standingChangeToIndex.getColor() == INSERT) { if(!allowContradictingEvents) throw new IllegalStateException("Remove " + i + " undoes prior insert at the same index! Consider enabling contradicting events."); tree.remove(overallIndex, ALL_INDICES, 1); continue; } // if we're deleting an update, the original replaced value stands. if(standingChangeToIndex.getColor() == UPDATE) { value = standingChangeToIndex.get(); } tree.set(overallIndex, ALL_INDICES, DELETE, value, 1); } }
/** * <p>We should consider removing the loop from this method by counting * the inserted elements between startIndex and endIndex, removing those, * then removing everything else... * * @param startIndex the index of the first element to remove * @param endIndex the last index, exclusive * @param value the removed value */ public void targetDelete(int startIndex, int endIndex, E value) { if(!initialCapacityKnown) ensureCapacity(endIndex); for(int i = startIndex; i < endIndex; i++) { if(startIndex > 0 && startIndex > tree.size(TARGET_INDICES)) { throw new IllegalArgumentException(); } int overallIndex = tree.convertIndexColor(startIndex, TARGET_INDICES, ALL_INDICES); Element<E> standingChangeToIndex = tree.get(overallIndex, ALL_INDICES); // if we're deleting an insert, remove that insert if(standingChangeToIndex.getColor() == INSERT) { if(!allowContradictingEvents) throw new IllegalStateException("Remove " + i + " undoes prior insert at the same index! Consider enabling contradicting events."); tree.remove(overallIndex, ALL_INDICES, 1); continue; } // if we're deleting an update, the original replaced value stands. if(standingChangeToIndex.getColor() == UPDATE) { value = standingChangeToIndex.get(); } tree.set(overallIndex, ALL_INDICES, DELETE, value, 1); } }
/** * <p>We should consider removing the loop from this method by counting * the inserted elements between startIndex and endIndex, removing those, * then removing everything else... * * @param startIndex the index of the first element to remove * @param endIndex the last index, exclusive * @param value the removed value */ public void targetDelete(int startIndex, int endIndex, E value) { if(!initialCapacityKnown) ensureCapacity(endIndex); for(int i = startIndex; i < endIndex; i++) { if(startIndex > 0 && startIndex > tree.size(TARGET_INDICES)) { throw new IllegalArgumentException(); } int overallIndex = tree.convertIndexColor(startIndex, TARGET_INDICES, ALL_INDICES); Element<E> standingChangeToIndex = tree.get(overallIndex, ALL_INDICES); // if we're deleting an insert, remove that insert if(standingChangeToIndex.getColor() == INSERT) { if(!allowContradictingEvents) throw new IllegalStateException("Remove " + i + " undoes prior insert at the same index! Consider enabling contradicting events."); tree.remove(overallIndex, ALL_INDICES, 1); continue; } // if we're deleting an update, the original replaced value stands. if(standingChangeToIndex.getColor() == UPDATE) { value = standingChangeToIndex.get(); } tree.set(overallIndex, ALL_INDICES, DELETE, value, 1); } }