alice.tuplemedium
Interface TupleSet

All Superinterfaces:
java.io.Serializable
All Known Implementing Classes:
TupleSetImpl

public interface TupleSet
extends java.io.Serializable

Specifies the services which must be provided by the component inside the tuple centre virtual machine collecting and managing tuples as a multiset An important aspect of the component implementing this interface is the ability to execute transactions, that is execute sequence of operations that could be commited or asked to be undone.

See Also:
Tuple, TupleTemplate, TupleCentreVM

Method Summary
 void add(Tuple t)
          Adds a tuple to the multiset
 void beginTransaction()
          Begins a transaction section Every operation on multiset can be undone
 void empty()
          Empties the multiset
 void endTransaction(boolean commit)
          Ends a transaction section specifying if operations must be committed or undone
 java.util.Iterator getIterator()
          Gets an iterator to navigate through tuples of the multiset
 Tuple getMatchingTuple(TupleTemplate t)
          Gets (and removes) non-deterministically a tuple of the multiset matching the template specified
 boolean hasMatchingTuple(TupleTemplate t)
          Checks if exists a tuple inside the tuple set matching the template
 boolean isEmpty()
          Tests if the multiset is empty
 Tuple readMatchingTuple(TupleTemplate t)
          Gets (wtihout removal) non-deterministically a tuple of the multiset matching the template specified
 int size()
          Gets the number of tuples inside the multiset
 void sub(Tuple t)
          Removes a tuple to the multiset
 

Method Detail

add

public void add(Tuple t)
Adds a tuple to the multiset
Parameters:
t - the tuple to be added

sub

public void sub(Tuple t)
Removes a tuple to the multiset
Parameters:
t - the tuple to be removed

size

public int size()
Gets the number of tuples inside the multiset

isEmpty

public boolean isEmpty()
Tests if the multiset is empty

empty

public void empty()
Empties the multiset

beginTransaction

public void beginTransaction()
Begins a transaction section Every operation on multiset can be undone

endTransaction

public void endTransaction(boolean commit)
Ends a transaction section specifying if operations must be committed or undone
Parameters:
commit - if true the operations are committed, else they are undone and the multiset is rolled back to the state before the beginTransaction invocation

getMatchingTuple

public Tuple getMatchingTuple(TupleTemplate t)
Gets (and removes) non-deterministically a tuple of the multiset matching the template specified
Parameters:
t - the tuple template to be used for the matching
Returns:
a tuple matching the template or null if no tuples found

readMatchingTuple

public Tuple readMatchingTuple(TupleTemplate t)
Gets (wtihout removal) non-deterministically a tuple of the multiset matching the template specified
Parameters:
t - the tuple template to be used for the matching
Returns:
a tuple matching the template or null if no tuples found

hasMatchingTuple

public boolean hasMatchingTuple(TupleTemplate t)
Checks if exists a tuple inside the tuple set matching the template
Parameters:
t - the tuple template to be used for the matching
Returns:
true if a masching is found, false otherwise

getIterator

public java.util.Iterator getIterator()
Gets an iterator to navigate through tuples of the multiset
Returns:
the iterator