Package jason.bb

Class IndexedBB

All Implemented Interfaces:
ToDOM, Cloneable, Iterable<Literal>

public class IndexedBB extends ChainBBAdapter
Customised version of Belief Base where some beliefs are unique (with primary keys) and indexed for faster access.

E.g. in a .mas2j project file:
agents: bob beliefBaseClass jason.bb.IndexedBB("student(key,_)", "depot(_,_,_)")
The belief "student/2" has the first argument as its key, so the BB will never has two students with the same key. Or, two students in the BB will have two different keys. The belief "depot/3" has no key, so there will be always only one "depot" in the BB. When some belief with the same key than another belief in BB is added, the most recent remains in the BB and the older is removed.

  • Constructor Details

    • IndexedBB

      public IndexedBB()
    • IndexedBB

      public IndexedBB(BeliefBase next)
  • Method Details

    • init

      public void init(Agent ag, String[] args)
      Description copied from class: BeliefBase
      Called before the MAS execution with the agent that uses this BB and the args informed in .mas2j project.
      Example in .mas2j:
      agent BeliefBaseClass(1,bla);
      the init args will be ["1", "bla"].
      Overrides:
      init in class ChainBBAdapter
    • add

      public boolean add(Literal bel) throws JasonException
      Description copied from class: BeliefBase
      Adds a belief in the end of the BB, returns true if succeed. The annots of l may be changed to reflect what was changed in the BB, for example, if l is p[a,b] in a BB with p[a], l will be changed to p[b] to produce the event +p[b], since only the annotation b is changed in the BB.
      Overrides:
      add in class ChainBBAdapter
      Throws:
      JasonException
    • clone

      public BeliefBase clone()
      Overrides:
      clone in class ChainBBAdapter