Class FieldArrayDictionary<T extends CalculusFieldElement<T>>

  • Type Parameters:
    T - the type of the field elements

    public class FieldArrayDictionary<T extends CalculusFieldElement<T>>
    extends Object
    String → CalculusFieldElement[] mapping, for small number of keys.

    This class is a low overhead for a very small number of keys. It is based on simple array and string comparison. It plays the same role a Map<String, T[]> but with reduced features and not intended for large number of keys. For such needs the regular Map<String, T[]> should be preferred.

    Since:
    11.1
    • Constructor Detail

      • FieldArrayDictionary

        public FieldArrayDictionary​(Field<T> field)
        Constructor with default initial capacity.
        Parameters:
        field - field to which the elements belong
      • FieldArrayDictionary

        public FieldArrayDictionary​(Field<T> field,
                                    int initialCapacity)
        Constructor with specified capacity.
        Parameters:
        field - field to which the elements belong
        initialCapacity - initial capacity
      • FieldArrayDictionary

        public FieldArrayDictionary​(FieldArrayDictionary<T> dictionary)
        Constructor from another dictionary.
        Parameters:
        dictionary - dictionary to use for initializing entries
      • FieldArrayDictionary

        public FieldArrayDictionary​(Field<T> field,
                                    Map<String,​T[]> map)
        Constructor from a map.
        Parameters:
        field - field to which the elements belong
        map - map to use for initializing entries
    • Method Detail

      • getField

        public Field<T> getField()
        Get the field to which elements belong.
        Returns:
        field to which elements belong
      • getData

        public List<FieldArrayDictionary.Entry> getData()
        Get an unmodifiable view of the dictionary entries.
        Returns:
        unmodifiable view of the dictionary entries
      • size

        public int size()
        Get the number of dictionary entries.
        Returns:
        number of dictionary entries
      • toMap

        public Map<String,​T[]> toMap()
        Create a map from the instance.

        The map contains a copy of the instance data

        Returns:
        copy of the dictionary, as an independent map
      • clear

        public void clear()
        Remove all entries.
      • put

        public void put​(String key,
                        T[] value)
        Add an entry.

        If an entry with the same key already exists, it will be removed first.

        The new entry is always put at the end.

        Parameters:
        key - entry key
        value - entry value
      • put

        public void put​(String key,
                        double[] value)
        Add an entry.

        If an entry with the same key already exists, it will be removed first.

        The new entry is always put at the end.

        Parameters:
        key - entry key
        value - entry value
      • putAll

        public void putAll​(Map<String,​T[]> map)
        Put all the entries from the map in the dictionary.
        Parameters:
        map - map to copy into the instance
      • putAll

        public void putAll​(FieldArrayDictionary<T> dictionary)
        Put all the entries from another dictionary.
        Parameters:
        dictionary - dictionary to copy into the instance
      • get

        public T[] get​(String key)
        Get the value corresponding to a key.
        Parameters:
        key - entry key
        Returns:
        copy of the value corresponding to the key or null if key not present
      • getEntry

        public FieldArrayDictionary.Entry getEntry​(String key)
        Get a complete entry.
        Parameters:
        key - entry key
        Returns:
        entry with key if it exists, null otherwise
      • remove

        public boolean remove​(String key)
        remove an entry.
        Parameters:
        key - key of the entry to remove
        Returns:
        true if an entry has been removed, false if the key was not present
      • unmodifiableView

        public FieldArrayDictionary<T> unmodifiableView()
        Get an unmodifiable view of the dictionary.

        The return dictionary is backed by the original instance and offers read-only access to it, but all operations that modify it throw an UnsupportedOperationException.

        Returns:
        unmodifiable view of the dictionary
      • toString

        public String toString()
        Get a string representation of the dictionary.

        This string representation is intended for improving displays in debuggers only.

        Overrides:
        toString in class Object
        Returns:
        string representation of the dictionary