1 47 48 package org.ozoneDB.collections; 49 50 import java.util.NoSuchElementException ; 51 import org.ozoneDB.OzoneObject; 52 53 58 public class _BaseList_SubList_listIterator extends OzoneObject implements OzoneListIterator { 59 60 private _BaseList_SubList subList; 61 private OzoneListIterator wrapped; 62 63 private int position; 64 65 public _BaseList_SubList_listIterator(_BaseList_SubList subList, OzoneListIterator wrapped) { 66 this.subList = subList; 67 this.wrapped = wrapped; 68 position = wrapped.nextIndex(); 69 } 70 71 public boolean hasNext() { 72 subList._org_ozoneDB_checkMod(); 73 return position < subList.size(); 74 } 75 76 public boolean hasPrevious() { 77 subList._org_ozoneDB_checkMod(); 78 return position > 0; 79 } 80 81 public Object next() { 82 if (position >= subList.size()) { 83 throw new NoSuchElementException (); 84 } 85 position++; 86 return wrapped.next(); 87 } 88 89 public Object previous() { 90 if (position <= 0) { 91 throw new NoSuchElementException (); 92 } 93 position--; 94 return wrapped.previous(); 95 } 96 97 public int nextIndex() { 98 return wrapped.nextIndex() - subList._org_ozoneDB_getOffset(); 99 } 100 101 public int previousIndex() { 102 return wrapped.previousIndex() - subList._org_ozoneDB_getOffset(); 103 } 104 105 public void remove() { 106 wrapped.remove(); 107 subList._org_ozoneDB_incSize(-1); 108 position = nextIndex(); 109 subList._org_ozoneDB_syncModCountWithBackingList(); 110 } 111 112 public void set(Object o) { 113 wrapped.set(o); 114 } 115 116 public void add(Object o) { 117 wrapped.add(o); 118 subList._org_ozoneDB_incSize(1); 119 position++; 120 subList._org_ozoneDB_syncModCountWithBackingList(); 121 } 122 123 } 142 | Popular Tags |