1 22 23 package com.sosnoski.util.queue; 24 25 import java.util.Iterator ; 26 27 import com.sosnoski.util.WrappedArrayIterator; 28 29 40 41 public class StringQueue extends QueueBase 42 { 43 44 protected String [] m_baseArray; 45 46 52 53 public StringQueue(int size, int growth) { 54 super(size, growth, String .class); 55 } 56 57 62 63 public StringQueue(int size) { 64 super(size, String .class); 65 } 66 67 70 71 public StringQueue() { 72 this(DEFAULT_SIZE); 73 } 74 75 80 81 public StringQueue(StringQueue base) { 82 super(base); 83 } 84 85 91 92 protected Object getArray() { 93 return m_baseArray; 94 } 95 96 102 103 protected void setArray(Object array) { 104 m_baseArray = (String []) array; 105 } 106 107 113 114 public void add(String item) { 115 int index = getAddIndex(); 116 m_baseArray[index] = item; 117 } 118 119 126 127 public String remove() { 128 int index = getRemoveIndex(); 129 String item = m_baseArray[index]; 130 m_baseArray[index] = null; 131 return item; 132 } 133 134 143 144 public final Iterator iterator() { 145 int end = m_fillOffset - 1; 146 if (end < 0) { 147 end = m_countLimit - 1; 148 } 149 return WrappedArrayIterator.buildIterator(m_baseArray, 150 m_emptyOffset, end); 151 } 152 153 159 160 public String [] toArray() { 161 return (String []) buildArray(String .class); 162 } 163 164 169 170 public Object clone() { 171 return new StringQueue(this); 172 } 173 } 174 | Popular Tags |