1 22 23 package com.sosnoski.util.hashset; 24 25 import java.lang.reflect.Array ; 26 import java.util.Iterator ; 27 28 import com.sosnoski.util.ObjectHashBase; 29 import com.sosnoski.util.SparseArrayIterator; 30 31 51 52 public abstract class ObjectSetBase extends ObjectHashBase 53 { 54 64 65 public ObjectSetBase(int count, double fill, Class type, Object tech) { 66 super(count, fill, type, tech); 67 } 68 69 74 75 public ObjectSetBase(ObjectSetBase base) { 76 super(base); 77 } 78 79 88 89 protected abstract boolean reinsert(int slot); 90 91 100 101 protected abstract void restructure(Object karray); 102 103 111 112 protected void reallocate(int size) { 113 114 Object keys = getKeyArray(); 116 Class type = keys.getClass().getComponentType(); 117 setKeyArray(Array.newInstance(type, size)); 118 119 restructure(keys); 121 } 122 123 131 132 protected void internalRemove(int slot) { 133 Object [] items = getKeyArray(); 134 items[slot] = null; 135 m_entryCount--; 136 while (items[(slot = stepSlot(slot))] != null) { 137 reinsert(slot); 138 } 139 } 140 141 149 150 public final Iterator iterator() { 151 return SparseArrayIterator.buildIterator(getKeyArray()); 152 } 153 } 154 | Popular Tags |