Class MutableMapping<T>

  • All Implemented Interfaces:
    OrdinalSetMapping<T>, java.io.Serializable, java.lang.Iterable<T>

    public class MutableMapping<T>
    extends java.lang.Object
    implements OrdinalSetMapping<T>, java.io.Serializable
    A bit set mapping based on an object array. This is not terribly efficient, but is useful for prototyping.
    See Also:
    Serialized Form
    • Constructor Detail

      • MutableMapping

        public MutableMapping​(java.lang.Object[] array)
        Throws:
        java.lang.IllegalArgumentException - if array is null
      • MutableMapping

        protected MutableMapping()
    • Method Detail

      • getMappedIndex

        public int getMappedIndex​(java.lang.Object o)
        Specified by:
        getMappedIndex in interface OrdinalSetMapping<T>
        Returns:
        the number of a given object, or -1 if the object is not currently in the range.
      • hasMappedIndex

        public boolean hasMappedIndex​(T o)
        Specified by:
        hasMappedIndex in interface OrdinalSetMapping<T>
        Returns:
        whether the given object is mapped by this mapping
      • add

        public int add​(T o)
        Add an object to the set of mapped objects.
        Specified by:
        add in interface OrdinalSetMapping<T>
        Returns:
        the integer to which the object is mapped.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • iterator

        public java.util.Iterator<T> iterator()
        Specified by:
        iterator in interface java.lang.Iterable<T>
      • makeSingleton

        public OrdinalSet<T> makeSingleton​(int i)
      • deleteMappedObject

        public void deleteMappedObject​(T n)
        Parameters:
        n -
      • getObjects

        public java.util.Collection<T> getObjects()
      • replace

        public void replace​(T a,
                            T b)
                     throws java.lang.IllegalArgumentException
        Replace a in this mapping with b.
        Throws:
        java.lang.IllegalArgumentException
      • put

        public void put​(int i,
                        T o)
        Add an object to the set of mapped objects at index i.
      • getSize

        public int getSize()
        Specified by:
        getSize in interface OrdinalSetMapping<T>
        Returns:
        the current size of the bijection