Class ElsaStack.IdentityArray

java.lang.Object
org.mapdb.elsa.ElsaStack
org.mapdb.elsa.ElsaStack.IdentityArray
Enclosing class:
ElsaStack

public static final class ElsaStack.IdentityArray extends ElsaStack
uses array with linear identity (==) search. Uses little memory, but performance degrades fast with number of objects on stack
  • Field Details

    • size

      private int size
    • data

      private Object[] data
    • forwardRefs

      public boolean forwardRefs
  • Constructor Details

    • IdentityArray

      public IdentityArray()
  • Method Details

    • add

      public void add(Object o)
      Specified by:
      add in class ElsaStack
    • identityIndexOf

      public int identityIndexOf(Object obj)
      This method is reason why ArrayList is not used. Search an item in list and returns its index. It uses identity rather than 'equalsTo' One could argue that TreeMap should be used instead, but we do not expect large object trees. This search is VERY FAST compared to Maps, it does not allocate new instances or uses method calls.
      Specified by:
      identityIndexOf in class ElsaStack
      Parameters:
      obj - to find in list
      Returns:
      index of object in list or -1 if not found
    • getSize

      public int getSize()
      Specified by:
      getSize in class ElsaStack
    • getInstance

      public Object getInstance(int i)
      Specified by:
      getInstance in class ElsaStack