LayerHash implements Layerable<KeyType> { public synchronized boolean moveUp(KeyType key) { if (!hash.containsKey(key)) { return false; } else { return zlist.moveUp(key); } }  int size(); ValueType get(KeyType key); List<KeyType> getKeysAsList(); synchronized void addToTop(KeyType key, ValueType value); synchronized void addToBottom(KeyType key, ValueType value); synchronized boolean moveToTop(KeyType element); synchronized boolean moveAbove(KeyType objectToMove, KeyType reference); synchronized boolean moveBeneath(KeyType objectToMove, KeyType reference); synchronized boolean moveToBottom(KeyType key); synchronized boolean moveUp(KeyType key); synchronized boolean moveDown(KeyType key); @Override List<KeyType> elements(); List<KeyType> keys(); synchronized boolean remove(KeyType key); ValueType getTop(); ValueType getBottom(); ValueType getAbove(KeyType key); ValueType getBeneath(KeyType key);  }
@Test public void moveUp() { layerHash.moveUp(obj3); assertEquals(obj1, layerHash.getTop()); assertEquals(obj3, layerHash.getBeneath(obj1)); assertEquals(obj2, layerHash.getBeneath(obj3)); layerHash.moveUp(obj3); assertEquals(obj3, layerHash.getTop()); assertEquals(obj1, layerHash.getBeneath(obj3)); assertEquals(obj2, layerHash.getBeneath(obj1)); layerHash.moveUp(obj3); assertEquals(obj3, layerHash.getTop()); assertEquals(obj1, layerHash.getBeneath(obj3)); assertEquals(obj2, layerHash.getBeneath(obj1)); }