DiffListBySkipList implements DiffList<DirectoryDiff> { @Override public void addFirst(DirectoryDiff diff) { final int nodeLevel = DirectoryDiffListFactory.randomLevel(); final SkipListNode[] nodePath = new SkipListNode[nodeLevel + 1]; Arrays.fill(nodePath, head); final SkipListNode newNode = new SkipListNode(diff, nodeLevel); for (int level = 0; level <= nodeLevel; level++) { if (level > 0) { final SkipListNode nextNode = head.getSkipNode(level); if (nextNode != null) { ChildrenDiff combined = combineDiff(newNode, nextNode, level); if (combined != null) { newNode.setSkipDiff(combined, level); } } } newNode.setSkipTo(nodePath[level].getSkipNode(level), level); nodePath[level].setSkipTo(newNode, level); } skipNodeList.add(0, newNode); } DiffListBySkipList(int capacity); @Override void addFirst(DirectoryDiff diff); @Override boolean addLast(DirectoryDiff diff); @Override DirectoryDiff get(int index); @Override DirectoryDiff remove(int index); @Override boolean isEmpty(); @Override int size(); @Override Iterator<DirectoryDiff> iterator(); @Override int binarySearch(int key); @Override List<DirectoryDiff> getMinListForRange(int fromIndex, int toIndex,
      INodeDirectory dir); @Override String toString(); static final Logger LOG; }
@Test public void testAddFirst() throws Exception { testAddFirst(NUM_SNAPSHOTS); }