home *** CD-ROM | disk | FTP | other *** search
- package COM.objectspace.jgl;
-
- import java.io.Serializable;
-
- public final class DequeIterator implements RandomAccessIterator, Serializable {
- Deque myDeque;
- int myBlockIndex;
- int myMapIndex;
-
- public DequeIterator() {
- }
-
- public DequeIterator(DequeIterator var1) {
- this.myDeque = var1.myDeque;
- this.myMapIndex = var1.myMapIndex;
- this.myBlockIndex = var1.myBlockIndex;
- }
-
- DequeIterator(Deque var1, int var2, int var3) {
- this.myDeque = var1;
- this.myBlockIndex = var2;
- this.myMapIndex = var3;
- }
-
- public Object clone() {
- return new DequeIterator(this);
- }
-
- public boolean atBegin() {
- return this.equals(this.myDeque.myStart);
- }
-
- public boolean atEnd() {
- return this.equals(this.myDeque.myFinish);
- }
-
- public boolean hasMoreElements() {
- return !this.equals(this.myDeque.myFinish);
- }
-
- public void advance() {
- if (++this.myBlockIndex == Deque.BLOCK_SIZE) {
- ++this.myMapIndex;
- this.myBlockIndex = 0;
- }
-
- }
-
- public void advance(int var1) {
- this.myBlockIndex += var1;
- if (this.myBlockIndex >= Deque.BLOCK_SIZE) {
- int var3 = this.myBlockIndex / Deque.BLOCK_SIZE;
- this.myMapIndex += var3;
- this.myBlockIndex %= Deque.BLOCK_SIZE;
- } else {
- if (this.myBlockIndex < 0) {
- int var2 = (Deque.BLOCK_SIZE - 1 - this.myBlockIndex) / Deque.BLOCK_SIZE;
- this.myMapIndex -= var2;
- this.myBlockIndex += var2 * Deque.BLOCK_SIZE;
- }
-
- }
- }
-
- public void retreat() {
- if (--this.myBlockIndex == -1) {
- --this.myMapIndex;
- this.myBlockIndex = Deque.BLOCK_SIZE - 1;
- }
-
- }
-
- public void retreat(int var1) {
- this.advance(-var1);
- }
-
- public Object nextElement() {
- Object var1 = this.myDeque.myMap[this.myMapIndex][this.myBlockIndex];
- if (++this.myBlockIndex == Deque.BLOCK_SIZE) {
- ++this.myMapIndex;
- this.myBlockIndex = 0;
- }
-
- return var1;
- }
-
- DequeIterator copy(int var1) {
- DequeIterator var2 = new DequeIterator(this);
- var2.advance(var1);
- return var2;
- }
-
- public int distance(ForwardIterator var1) {
- DequeIterator var2 = (DequeIterator)var1;
- int var3 = var2.myBlockIndex - this.myBlockIndex;
- return this.myMapIndex == var2.myMapIndex ? var3 : Deque.BLOCK_SIZE * (var2.myMapIndex - this.myMapIndex) + var3;
- }
-
- public int index() {
- return this.myDeque.myStart.distance(this);
- }
-
- public Object get() {
- return this.myDeque.myMap[this.myMapIndex][this.myBlockIndex];
- }
-
- public void put(Object var1) {
- this.myDeque.myMap[this.myMapIndex][this.myBlockIndex] = var1;
- }
-
- public Object get(int var1) {
- int var2 = this.myMapIndex;
- int var3 = this.myBlockIndex;
- this.advance(var1);
- Object var4 = this.myDeque.myMap[this.myMapIndex][this.myBlockIndex];
- this.myMapIndex = var2;
- this.myBlockIndex = var3;
- return var4;
- }
-
- public void put(int var1, Object var2) {
- int var3 = this.myMapIndex;
- int var4 = this.myBlockIndex;
- this.advance(var1);
- this.myDeque.myMap[this.myMapIndex][this.myBlockIndex] = var2;
- this.myMapIndex = var3;
- this.myBlockIndex = var4;
- }
-
- public boolean equals(Object var1) {
- return var1 instanceof DequeIterator && this.equals((DequeIterator)var1);
- }
-
- public boolean equals(DequeIterator var1) {
- return this.myBlockIndex == var1.myBlockIndex && this.myMapIndex == var1.myMapIndex && this.myDeque == var1.myDeque;
- }
-
- public boolean less(RandomAccessIterator var1) {
- DequeIterator var2 = (DequeIterator)var1;
- return this.myMapIndex < var2.myMapIndex || this.myMapIndex == var2.myMapIndex && this.myBlockIndex < var2.myBlockIndex;
- }
-
- public Container getContainer() {
- return this.myDeque;
- }
- }
-