Advertisement
vovacomua

Untitled

Jan 19th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1.  
  2. class CustomList{
  3. TreeSet indexes;
  4. HahMap items;
  5. int maxSize = 0;
  6. int realSize = 0;
  7. add(Object item) {
  8. int curItemIndex = maxSize++;
  9. realSize ++;
  10. indexes.add(curItemIndex);
  11. items.put(curItemIndex, item);
  12. }
  13. remove(int index) {
  14. int realIndex = indexes.getByIndex(index);
  15. realSize--;
  16. indexes.remove(realIndex)
  17. item.remove(realIndex);
  18. }
  19.  
  20. getByIndex(int index) {
  21. int realIndex = indexes.getByIndex(index);
  22. return items.get(realIndex);
  23. }
  24.  
  25.  
  26.  
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement