grinda.impl.tuplespace
Class SimpleContainer

java.lang.Object
  extended by grinda.impl.tuplespace.SimpleContainer
All Implemented Interfaces:
TupleContainer

public class SimpleContainer
extends java.lang.Object
implements TupleContainer

This is a simple implementation of a TupleContainer using a vector to store objects. It is used instead of the HashContainer to store few tuples with better memory consumption.


Constructor Summary
SimpleContainer(InternalTuple absoluteTemplate)
           
 
Method Summary
 void add(InternalTuple t)
          Adds an InternalTuple to the container
 InternalTuple getAbsoluteTemplate()
           
 boolean isEmpty()
          Checks if the container is empty
 InternalTuple lookup(InternalTuple pattern)
          Looks up a tuples that match the given template using the associative matching
 InternalTuple[] lookupAll(InternalTuple pattern)
          Looks up all the tuples that match the given template using the associative matching
 InternalTuple remove(InternalTuple pattern)
          Removes a the tuple that match the given template using the associative matching
 InternalTuple[] removeAll(InternalTuple pattern)
          Removes all the tuples that match the given template using the associative matching
 int size()
          Gets the number of tuple stored
 java.util.Collection tuples()
          Gets a collection of all the tuple stored
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleContainer

public SimpleContainer(InternalTuple absoluteTemplate)
Method Detail

add

public void add(InternalTuple t)
Description copied from interface: TupleContainer
Adds an InternalTuple to the container

Specified by:
add in interface TupleContainer
Parameters:
t - the tuple

lookupAll

public InternalTuple[] lookupAll(InternalTuple pattern)
Description copied from interface: TupleContainer
Looks up all the tuples that match the given template using the associative matching

Specified by:
lookupAll in interface TupleContainer
Parameters:
pattern - the template
Returns:
the matching tuples or null if there are nones

lookup

public InternalTuple lookup(InternalTuple pattern)
Description copied from interface: TupleContainer
Looks up a tuples that match the given template using the associative matching

Specified by:
lookup in interface TupleContainer
Parameters:
pattern - the template
Returns:
a tuples found or null if there is none

remove

public InternalTuple remove(InternalTuple pattern)
Description copied from interface: TupleContainer
Removes a the tuple that match the given template using the associative matching

Specified by:
remove in interface TupleContainer
Parameters:
pattern - the template
Returns:
the tuple removed or null if there are none

removeAll

public InternalTuple[] removeAll(InternalTuple pattern)
Description copied from interface: TupleContainer
Removes all the tuples that match the given template using the associative matching

Specified by:
removeAll in interface TupleContainer
Parameters:
pattern - the template
Returns:
the tuples removed or null if there are nones

getAbsoluteTemplate

public InternalTuple getAbsoluteTemplate()

size

public int size()
Description copied from interface: TupleContainer
Gets the number of tuple stored

Specified by:
size in interface TupleContainer
Returns:
the size

isEmpty

public boolean isEmpty()
Description copied from interface: TupleContainer
Checks if the container is empty

Specified by:
isEmpty in interface TupleContainer
Returns:
true if it is empty false otherwise

tuples

public java.util.Collection tuples()
Description copied from interface: TupleContainer
Gets a collection of all the tuple stored

Specified by:
tuples in interface TupleContainer
Returns:
tuples


Copyright © 2006 Sirio Capizzi. All Rights Reserved.