FileDocCategorySizeDatePackage
IntMapper.javaAPI DocApache Poi 3.0.12634Mon Jan 01 12:39:42 GMT 2007org.apache.poi.util

IntMapper

public class IntMapper extends Object
A List of objects that are indexed AND keyed by an int; also allows for getting the index of a value in the list

I am happy is someone wants to re-implement this without using the internal list and hashmap. If so could you please make sure that you can add elements half way into the list and have the value-key mappings update

author
Jason Height

Fields Summary
private List
elements
private Map
valueKeyMap
private static final int
_default_size
Constructors Summary
public IntMapper()
create an IntMapper of default size


               

     
    
        this(_default_size);
    
public IntMapper(int initialCapacity)

        elements = new ArrayList(initialCapacity);
        valueKeyMap = new HashMap(initialCapacity);
    
Methods Summary
public booleanadd(java.lang.Object value)
Appends the specified element to the end of this list

param
value element to be appended to this list.
return
true (as per the general contract of the Collection.add method).

      int index = elements.size();
      elements.add(value);
      valueKeyMap.put(value, new Integer(index));
      return true;
    
public java.lang.Objectget(int index)

      return elements.get(index);
    
public intgetIndex(java.lang.Object o)

      Integer i = ((Integer)valueKeyMap.get(o));
      if (i == null)
        return -1;
      return i.intValue();
    
public java.util.Iteratoriterator()

      return elements.iterator();
    
public intsize()

      return elements.size();