1 22 23 package com.sosnoski.util.stack; 24 25 import com.sosnoski.util.*; 26 27 46 47 public abstract class StackBase extends GrowableBase 48 { 49 50 protected int m_countPresent; 51 52 59 60 public StackBase(int size, int growth, Class type) { 61 super(size, growth, type); 62 } 63 64 70 71 public StackBase(int size, Class type) { 72 this(size, Integer.MAX_VALUE, type); 73 } 74 75 80 81 public StackBase(StackBase base) { 82 super(base); 83 System.arraycopy(base.getArray(), 0, getArray(), 0, 84 base.m_countPresent); 85 m_countPresent = base.m_countPresent; 86 } 87 88 96 97 protected int getAddIndex() { 98 int index = m_countPresent++; 99 if (m_countPresent > m_countLimit) { 100 growArray(m_countPresent); 101 } 102 return index; 103 } 104 105 110 111 public int size() { 112 return m_countPresent; 113 } 114 115 120 121 public boolean isEmpty() { 122 return m_countPresent == 0; 123 } 124 125 128 129 public void clear() { 130 discardValues(0, m_countPresent); 131 m_countPresent = 0; 132 } 133 134 143 144 protected Object buildArray(Class type) { 145 return super.buildArray(type, 0, m_countPresent); 146 } 147 } 148 | Popular Tags |