jill/src/main/java/io/github/agentsoz/jill/core/beliefbase/abs/ABeliefStore.java
@Override
  public boolean addBelief(int agentid, String beliefsetName, Object... tuple)
      throws BeliefBaseException {
    // Check that the beliefset exists
    if (!beliefsets.containsKey(beliefsetName)) {
      throw new BeliefBaseException("Belief set '" + beliefsetName + "' does not exist");
    }
    // Create a new Belief
    Belief belief = new Belief(beliefs.size(), beliefsets.get(beliefsetName).getId(), tuple);
    // Add it to the list of beliefs
    int id;
    if (!beliefs.containsKey(belief)) {
      id = beliefs.size();
      beliefs.put(belief, id);
      beliefsByID.put(belief.getId(), belief);

    } else {
      id = beliefs.get(belief);
    }
    // Add it to the agents beliefs
    SparseBitSet bits = agents2beliefs[agentid];
    if (bits == null) {
      bits = new SparseBitSet();
    }
    bits.set(id);
    agents2beliefs[agentid] = bits;
    // Update the cached results
    for (String query : cachedresults.keySet()) {
      Set<Belief> results = cachedresults.get(query);
      if (match(belief, queries.get(query))) {
        results.add(belief);
      }
    }
    return true;
  }
@Override
  public boolean addBelief(int agentid, String beliefsetName, Object... tuple)
      throws BeliefBaseException {
    // Check that the beliefset exists
    if (!beliefsets.containsKey(beliefsetName)) {
      throw new BeliefBaseException("Belief set '" + beliefsetName + "' does not exist");
    }
    // Create a new Belief
    Belief belief = new Belief(beliefs.size(), beliefsets.get(beliefsetName).getId(), tuple);
    // Add it to the list of beliefs
    int id;
    if (!beliefs.containsKey(belief)) {
      id = beliefs.size();
      beliefs.put(belief, id);
      beliefsByID.put(belief.getId(), belief);

    } else {
      id = beliefs.get(belief);
    }
    // Add it to the agents beliefs
    SparseBitSet bits = agents2beliefs[agentid];
    if (bits == null) {
      bits = new SparseBitSet();
    }
    bits.set(id);
    agents2beliefs[agentid] = bits;
    // Update the cached results
    for (String query : cachedresults.keySet()) {
      Set<Belief> results = cachedresults.get(query);
      if (match(belief, queries.get(query))) {
        results.add(belief);
      }
    }
    return true;
  }
@ Override public boolean addBelief ( int agentid , String beliefsetName , Object ... tuple ) throws BeliefBaseException { // Check that the beliefset exists if ( ! beliefsets . containsKey ( beliefsetName ) ) { throw new BeliefBaseException ( "Belief set '" + beliefsetName + "' does not exist" ) ; } // Create a new Belief Belief belief = new Belief ( beliefs . size ( ) , beliefsets . get ( beliefsetName ) . getId ( ) , tuple ) ; // Add it to the list of beliefs int id ; if ( ! beliefs . containsKey ( belief ) ) { id = beliefs . size ( ) ; beliefs . put ( belief , id ) ; beliefsByID . put ( belief . getId ( ) , belief ) ; } else { id = beliefs . get ( belief ) ; } // Add it to the agents beliefs SparseBitSet bits = agents2beliefs [ agentid ] ; if ( bits == null ) { bits = new SparseBitSet ( ) ; } bits . set ( id ) ; agents2beliefs [ agentid ] = bits ; // Update the cached results for ( String query : cachedresults . keySet ( ) ) { Set < Belief > results = cachedresults . get ( query ) ; if ( match ( belief , queries . get ( query ) ) ) { results . add ( belief ) ; } } return true ; }
{@inheritDoc}.
{