/** * Expands the set to accommodate new values. * * @param newCapacity an <code>int</code> value */ @Override protected void rehash(int newCapacity) { TIntLinkedList oldOrder = new TIntLinkedList(order); int oldSize = size(); Object oldSet[] = _set; order.clear(); _set = new Object[newCapacity]; Arrays.fill(_set, FREE); for (TIntIterator iterator = oldOrder.iterator(); iterator.hasNext();) { int i = iterator.next(); E o = (E) oldSet[i]; if (o == FREE || o == REMOVED) { throw new IllegalStateException("Iterating over empty location while rehashing"); } if (o != FREE && o != REMOVED) { int index = insertKey(o); if (index < 0) { // everyone pays for this because some people can't RTFM throwObjectContractViolation(_set[(-index - 1)], o, size(), oldSize, oldSet); } if (!order.add(index)) throw new IllegalStateException("Order not changed after insert"); } } }
public String toString(){ StringBuilder sb = new StringBuilder(); TIntObjectHashMap<TLinkedHashSet<String>> sets = new TIntObjectHashMap<TLinkedHashSet<String>>(); for(int i=0;i<alpahbet.size();i++){ int head = getHead(i); TLinkedHashSet<String> s = sets.get(head); if(s==null){ s = new TLinkedHashSet(); sets.put(head, s); } s.add(alpahbet.lookupString(i)); } TIntObjectIterator<TLinkedHashSet<String>> it = sets.iterator(); while(it.hasNext()){ it.advance(); if(it.value().size()<2) continue; sb.append(wordProb.get(it.key())); sb.append(" "); TObjectHashIterator<String> itt = it.value().iterator(); while(itt.hasNext()){ String ss = itt.next(); sb.append(ss); sb.append(" "); } sb.append("\n"); } return sb.toString(); }
/** * Expands the set to accommodate new values. * * @param newCapacity an <code>int</code> value */ @Override protected void rehash(int newCapacity) { TIntLinkedList oldOrder = new TIntLinkedList(order); int oldSize = size(); Object oldSet[] = _set; order.clear(); _set = new Object[newCapacity]; Arrays.fill(_set, FREE); for (TIntIterator iterator = oldOrder.iterator(); iterator.hasNext();) { int i = iterator.next(); E o = (E) oldSet[i]; if (o == FREE || o == REMOVED) { throw new IllegalStateException("Iterating over empty location while rehashing"); } if (o != FREE && o != REMOVED) { int index = insertKey(o); if (index < 0) { // everyone pays for this because some people can't RTFM throwObjectContractViolation(_set[(-index - 1)], o, size(), oldSize, oldSet); } if (!order.add(index)) throw new IllegalStateException("Order not changed after insert"); } } }
/** * Expands the set to accommodate new values. * * @param newCapacity an <code>int</code> value */ @Override @SuppressWarnings("unchecked") protected void rehash(int newCapacity) { TIntLinkedList oldOrder = new TIntLinkedList(order); int oldSize = size(); Object oldSet[] = _set; order.clear(); _set = new Object[newCapacity]; Arrays.fill(_set, FREE); for (TIntIterator iterator = oldOrder.iterator(); iterator.hasNext();) { int i = iterator.next(); E o = (E) oldSet[i]; if (o == FREE || o == REMOVED) { throw new IllegalStateException("Iterating over empty location while rehashing"); } if (o != FREE && o != REMOVED) { int index = insertKey(o); if (index < 0) { // everyone pays for this because some people can't RTFM throwObjectContractViolation(_set[(-index - 1)], o, size(), oldSize, oldSet); } if (!order.add(index)) throw new IllegalStateException("Order not changed after insert"); } } }