Class AgentProgram

  • All Implemented Interfaces:
    java.util.Map<Formula,​Action>

    public final class AgentProgram
    extends java.lang.Object
    implements java.util.Map<Formula,​Action>
    Class representing an ordered map specifically implemented to handle agent program.
    • Nested Class Summary

      • Nested classes/interfaces inherited from interface java.util.Map

        java.util.Map.Entry<K extends java.lang.Object,​V extends java.lang.Object>
    • Constructor Detail

      • AgentProgram

        public AgentProgram​(java.util.List<Formula> keys,
                            java.util.List<Action> values)
        Constructor. The argument were copied to a new array to avoid outside modifications.
        Parameters:
        keys - list of keys
        values - list of associated values to the keys
      • AgentProgram

        public AgentProgram​(AgentProgram other)
        Copy constructor.
        Parameters:
        other - other program to copy
      • AgentProgram

        public AgentProgram()
        Default constructor. Initialize the two inner lists at an empty array.
    • Method Detail

      • equals

        public boolean equals​(java.lang.Object other)
        Specified by:
        equals in interface java.util.Map<Formula,​Action>
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Specified by:
        hashCode in interface java.util.Map<Formula,​Action>
        Overrides:
        hashCode in class java.lang.Object
      • clear

        public void clear()
        Specified by:
        clear in interface java.util.Map<Formula,​Action>
      • containsKey

        public boolean containsKey​(java.lang.Object key)
        Specified by:
        containsKey in interface java.util.Map<Formula,​Action>
      • containsValue

        public boolean containsValue​(java.lang.Object value)
        Specified by:
        containsValue in interface java.util.Map<Formula,​Action>
      • entrySet

        public java.util.Set<java.util.Map.Entry<Formula,​Action>> entrySet()
        Specified by:
        entrySet in interface java.util.Map<Formula,​Action>
      • get

        public Action get​(java.lang.Object key)
        Specified by:
        get in interface java.util.Map<Formula,​Action>
      • getKey

        public Formula getKey​(int index)
        Gets the key (formula) at a specified index.
        Parameters:
        index - specified index
        Returns:
        associated key of the index
      • getValue

        public Action getValue​(int index)
        Gets the value (action) at a specified index.
        Parameters:
        index - specified index
        Returns:
        associated action of the index
      • getIndex

        public int getIndex​(Formula arg0)
        Gets the index of a key.
        Parameters:
        arg0 - key to get the index of it
        Returns:
        index of the given key
      • isEmpty

        public boolean isEmpty()
        Specified by:
        isEmpty in interface java.util.Map<Formula,​Action>
      • keySet

        public java.util.Set<Formula> keySet()
        Specified by:
        keySet in interface java.util.Map<Formula,​Action>
      • insert

        public int insert​(int index,
                          Formula key,
                          Action value)
        Inserts a key and associated value to a specific index. If the key is already in the map, the key is remove from the list and reinsert at the given index. If specified index is greater than the size of map, we put the couple key/value at the end of the map. If the given key is null, we put at the end or if the given index is the last index of the list, we check if we need to move the null element at the end.
        Parameters:
        index - index to place key and value
        key - key to insert
        value - value to insert
        Returns:
        index that the key/value inserted
      • putAll

        public void putAll​(java.util.Map<? extends Formula,​? extends Action> m)
        Specified by:
        putAll in interface java.util.Map<Formula,​Action>
      • putAll

        public void putAll​(java.util.List<Formula> arg0,
                           java.util.List<Action> arg1)
        Puts all the given keys and associated values to the map object.
        Parameters:
        arg0 - list of keys
        arg1 - list of associated values to the keys
      • remove

        public Action remove​(java.lang.Object key)
        Specified by:
        remove in interface java.util.Map<Formula,​Action>
      • size

        public int size()
        Specified by:
        size in interface java.util.Map<Formula,​Action>
      • values

        public java.util.Collection<Action> values()
        Specified by:
        values in interface java.util.Map<Formula,​Action>
      • getKeysBeforeAt

        public java.util.List<Formula> getKeysBeforeAt​(int index)
        Gets all formulas before a specified index. Given index excluded. If index == 0, an empty array is returned.
        Parameters:
        index - specified index
        Returns:
        sublist of keys from 0 included to index excluded.
      • getOrderedKeys

        public java.util.List<Formula> getOrderedKeys()
        Gets the keys in the right order.
        Returns:
        ordered keys
      • getOrderedValues

        public java.util.List<Action> getOrderedValues()
        Gets the values in the right order.
        Returns:
        ordered values