Package MAKBPInterpreter.agents
Class AgentProgram
- java.lang.Object
-
- MAKBPInterpreter.agents.AgentProgram
-
-
Constructor Summary
Constructors Constructor Description AgentProgram()
Default constructor.AgentProgram(java.util.List<Formula> keys, java.util.List<Action> values)
Constructor.AgentProgram(AgentProgram other)
Copy constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
boolean
containsKey(java.lang.Object key)
boolean
containsValue(java.lang.Object value)
java.util.Set<java.util.Map.Entry<Formula,Action>>
entrySet()
boolean
equals(java.lang.Object other)
Action
get(java.lang.Object key)
int
getIndex(Formula arg0)
Gets the index of a key.Formula
getKey(int index)
Gets the key (formula) at a specified index.java.util.List<Formula>
getKeysBeforeAt(int index)
Gets all formulas before a specified index.java.util.List<Formula>
getOrderedKeys()
Gets the keys in the right order.java.util.List<Action>
getOrderedValues()
Gets the values in the right order.Action
getValue(int index)
Gets the value (action) at a specified index.int
hashCode()
int
insert(int index, Formula key, Action value)
Inserts a key and associated value to a specific index.boolean
isEmpty()
java.util.Set<Formula>
keySet()
Action
put(Formula arg0, Action arg1)
void
putAll(java.util.List<Formula> arg0, java.util.List<Action> arg1)
Puts all the given keys and associated values to the map object.void
putAll(java.util.Map<? extends Formula,? extends Action> m)
Action
remove(java.lang.Object key)
int
size()
java.util.Collection<Action>
values()
-
-
-
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 keysvalues
- 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)
-
hashCode
public int hashCode()
-
containsKey
public boolean containsKey(java.lang.Object key)
-
containsValue
public boolean containsValue(java.lang.Object value)
-
get
public Action get(java.lang.Object key)
-
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
-
keySet
public java.util.Set<Formula> keySet()
-
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 valuekey
- key to insertvalue
- value to insert- Returns:
- index that the key/value inserted
-
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 keysarg1
- list of associated values to the keys
-
remove
public Action remove(java.lang.Object key)
-
values
public java.util.Collection<Action> values()
-
getKeysBeforeAt
public java.util.List<Formula> getKeysBeforeAt(int index)
Gets all formulas before a specified index. Given index excluded. Ifindex == 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
-
-