Class DistributedList
java.lang.Object
edu.jas.util.DistributedList
Distributed version of a List.
Implemented with a SortedMap / TreeMap to keep the sequence order of elements.
- Author:
- Heinz Kredel
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final ChannelFactoryprotected SocketChannelprotected edu.jas.util.Listener -
Constructor Summary
ConstructorsConstructorDescriptionDistributedList(ChannelFactory cf, String host, int port) Constructor for DistributedList.Constructor for DistributedList.DistributedList(String host) Constructor for DistributedList.DistributedList(String host, int port) Constructor for DistributedList. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd object to the list and distribute to other lists.voidclear()Clear the List. caveat: must be called on all clients.getList()Get the internal list, convert from Collection.voidinit()List thread initialization and start.booleanisEmpty()Is the List empty?iterator()List iterator.intsize()Size of the (local) list.voidTerminate the list thread.
-
Field Details
-
theList
-
cf
-
channel
-
listener
protected edu.jas.util.Listener listener
-
-
Constructor Details
-
DistributedList
Constructor for DistributedList.- Parameters:
host- name or IP of server host.
-
DistributedList
Constructor for DistributedList.- Parameters:
host- name or IP of server host.port- of server.
-
DistributedList
Constructor for DistributedList.- Parameters:
cf- ChannelFactory to use.host- name or IP of server host.port- of server.
-
DistributedList
Constructor for DistributedList.- Parameters:
sc- SocketChannel to use.
-
-
Method Details
-
init
public void init()List thread initialization and start. -
terminate
public void terminate()Terminate the list thread. -
getList
-
size
public int size()Size of the (local) list. -
add
Add object to the list and distribute to other lists. Blocks until the object is send and received from the server (actually it blocks until some object is received).- Parameters:
o-
-
clear
public void clear()Clear the List. caveat: must be called on all clients. -
isEmpty
public boolean isEmpty()Is the List empty? -
iterator
List iterator.
-