Hazelcast Set is a distributed and concurrent implementation of java.util.Set
.
java.util.HashSet
.Use the HazelcastInstance getSet
method to get the Set, then use the set put
method to put items into the Set.
import com.hazelcast.core.Hazelcast;
import java.util.Set;
import java.util.Iterator;
HazelcastInstance hazelcastInstance = Hazelcast.newHazelcastInstance();
Set<Price> set = hazelcastInstance.getSet( "IBM-Quote-History" );
set.add( new Price( 10, time1 ) );
set.add( new Price( 11, time2 ) );
set.add( new Price( 12, time3 ) );
set.add( new Price( 11, time4 ) );
//....
Iterator<Price> iterator = set.iterator();
while ( iterator.hasNext() ) {
Price price = iterator.next();
//analyze
}
Hazelcast Set uses ItemListener
to listen to events which occur when items are added to and removed from the Set. Please refer to the Listening for Item Events section for information on how to create an item listener class and register it.
RELATED INFORMATION
Please refer to the Set Configuration section for a full description of Hazelcast Distributed Set configuration.