|
Objectivity for Java Reference | |||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.objy.db.app.ooAbstractObj | +--com.objy.db.app.ooObj | +--com.objy.db.util.ooCollection | +--com.objy.db.util.ooHashSet
Persistence-capable class for unordered sets of persistent objects.
API Summary |
You may not create your own subclasses of this class.
An unordered set is an unordered collection of persistent objects with no duplicate elements. Unordered sets are scalable collections, that is, they can increase in size with minimal performance degradation. They are implemented using an extendible hashing mechanism so that elements can be added, deleted, and retrieved efficiently. The hash value for each element is computed from the element itself.
The hash values for elements of an unordered set are computed by the set's associated comparator. If an unordered set has a default comparator, the hash values are computed from the OIDs of the elements.
For additional information, see Persistent Collections.
An unordered set is transient when it is created. You can make the set persistent in any of the ways that you make any basic object persistent (see Making an Object Persistent). You can store and retrieve the set just like any other persistent object. For example, you can store a set in a persistent field of a persistent object.
Note: You must make a set persistent before you call any methods defined by the ooHashSet or ooCollection classes. See the ooObj method descriptions for restrictions on methods inherited from that class.
Like any persistent object, a set belongs to the session that is in a transaction when the set is made persistent or retrieved. Objectivity/DB does not allow a set to interact with objects that belong to different sessions; see Object Isolation.
Two additional classes represent persistent collections of persistent objects:
Both sorted sets and lists are implemented using a B-tree data structure.
Functionality | |
Constructors |
ooHashSet() ooHashSet(ooCompare) ooHashSet(int) ooHashSet(ooCompare, int) ooHashSet(int, ooContObj, ooContObj) ooHashSet(ooCompare, int, ooContObj, ooContObj) ooHashSet(ooCompare, int, int, ooContObj, ooContObj) |
Adding and Removing Elements |
addAll(Collection) remove(Object) ooRemove(Object) removeAll(Collection) retainAll(Collection) |
Getting Elements |
iterator() get(Object) |
Testing |
containsAll(Collection) |
Setting Properties | maxBucketsPerContainer(int) |
Field Summary | |
ooContObj |
_adminContainer
Reserved for internal use. |
ooContObj |
_bucketContainer
Reserved for internal use. |
int |
_bucketSize
Reserved for internal use. |
int |
_initialBuckets
Reserved for internal use. |
Fields inherited from class com.objy.db.util.ooCollection |
_comparator |
Constructor Summary | |
ooHashSet()
Constructs an empty unordered set with a default comparator, the default hash-bucket size, one initial hash bucket, a newly created administrator container, and a newly created hash-bucket container. |
|
ooHashSet(int bucketSize)
Constructs an empty unordered set with the specified hash-bucket size, a default comparator, one initial hash bucket, a newly created administrator container, and a newly created hash-bucket container. |
|
ooHashSet(int initialBuckets,
ooContObj adminContainer,
ooContObj bucketContainer)
Constructs an empty unordered set with a default comparator, the default hash-bucket size, and the specified number of initial hash buckets, administrator container, and hash-bucket container. |
|
ooHashSet(ooCompare compare)
Constructs an empty unordered set with the specified comparator, the default hash-bucket size, one initial hash bucket, a newly created administrator container, and a newly created hash-bucket container. |
|
ooHashSet(ooCompare compare,
int bucketSize)
Constructs an empty unordered set with the specified comparator and hash-bucket size, one initial hash bucket, a newly created administrator container, and a newly created hash-bucket container. |
|
ooHashSet(ooCompare compare,
int bucketSize,
int initialBuckets,
ooContObj adminContainer,
ooContObj bucketContainer)
Constructs an empty unordered set with the specified comparator, hash-bucket size, number of initial hash buckets, administrator container, and hash-bucket container. |
|
ooHashSet(ooCompare compare,
int initialBuckets,
ooContObj adminContainer,
ooContObj bucketContainer)
Constructs an empty unordered set with the default hash-bucket size and the specified comparator, number of initial hash buckets, administrator container, and hash-bucket container. |
Method Summary | |
boolean |
addAll(Collection collection)
Adds all elements in the specified collection to this unordered set. |
boolean |
containsAll(Collection collection)
Tests whether this unordered set contains all elements in the specified collection. |
Object |
get(Object lookupValue)
Gets the element of this unordered set that is equal to the specified lookup data, as determined by the comparator for this unordered set. |
Iterator |
iterator()
Initializes a collection iterator to find the elements of this unordered set. |
void |
maxBucketsPerContainer(int max)
Sets the maximum number of hash buckets per container for this unordered set. |
boolean |
ooRemove(Object object)
Removes the specified object from this unordered set. |
boolean |
remove(Object object)
Removes the specified object from this unordered set. |
boolean |
removeAll(Collection collection)
Removes all elements of the specified collection from this unordered set. |
boolean |
retainAll(Collection collection)
Retains all elements of this unordered set that are also in the specified collection, deleting all other elements. |
Methods inherited from class com.objy.db.util.ooCollection |
add, clear, comparator, contains, copy, getCollectionPersistor, isEmpty, keyIterator, ooAddAll, ooContainsAll, ooIterator, ooRemoveAll, ooRetainAll, refresh, removeAllDeleted, size, toArray, toArray |
Methods inherited from class com.objy.db.app.ooObj |
activate, clearModified, cluster, deactivate, delete, deleteNoProp, deleteReference, dropCachedReference, fetch, fetch, getContainer, getOid, getPersistor, getSession, isDead, isFetchRequired, isModified, isPersistent, isValid, lock, lockNoProp, lookupObj, lookupObj, lookupObjName, markFetchRequired, markModified, move, nameObj, persistor, preWrite, scopedBy, scopedObjects, setPersistor, unnameObj, updateIndexes, write |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface java.util.Set |
add, clear, contains, equals, hashCode, isEmpty, size, toArray, toArray |
Field Detail |
public transient int _bucketSize
public transient ooContObj _adminContainer
public transient int _initialBuckets
public transient ooContObj _bucketContainer
Constructor Detail |
public ooHashSet()
public ooHashSet(int bucketSize)
bucketSize
- The size of a hash bucket
in the new unordered set's hash table. The size of
a hash bucket is the number of elements that can be hashed into each
bucket. For optimal performance, the bucket size should be a prime
number. If you specify a bucket size that is not a prime number, the
next higher prime number is computed and used as the actual bucket
size.public ooHashSet(ooCompare compare)
compare
- The comparator for the new set; must be
an instance of an application-specific subclass of
ooCompare.public ooHashSet(ooCompare compare, int bucketSize)
compare
- The comparator for the new set; must be
an instance of an application-specific subclass of
ooCompare.bucketSize
- The size of a hash bucket
in the new unordered set's hash table. The size of
a hash bucket is the number of elements that can be hashed into each
bucket. For optimal performance, the bucket size should be a prime
number. If you specify a bucket size that is not a prime number, the
next higher prime number is computed and used as the actual bucket
size.public ooHashSet(int initialBuckets, ooContObj adminContainer, ooContObj bucketContainer)
initialBuckets
- The minimum number of
initial hash buckets to create for the new unordered set. The
actual number of hash buckets created is the smallest power of 2 that
is greater than initialBuckets. For example, if
initialBuckets is 10, the number of initial hash
buckets is 2**4, or 16.
Preallocating multiple hash buckets increases the speed of adding and finding elements. If each hash bucket is stored in a separate container, preallocating hash buckets also reduces the chance of lock conflicts. However, an unordered set with a large number of initial hash buckets requires more disk space, more memory for the directory, and more time to create.
adminContainer
- The container in
which to store the hash administrator for the new unordered
set; specify null to store the hash administrator in a newly
created container. bucketContainer
- The container in
which to store the initial hash buckets for the new unordered
set; specify null to store each initial hash bucket in its
own newly created container.public ooHashSet(ooCompare compare, int initialBuckets, ooContObj adminContainer, ooContObj bucketContainer)
compare
- The comparator for the new set; must be
an instance of an application-specific subclass of
ooCompare.initialBuckets
- The minimum number of
initial hash buckets to create for the new unordered set. The
actual number of hash buckets created is the smallest power of 2 that
is greater than initialBuckets. For example, if
initialBuckets is 10, the number of initial hash
buckets is 2**4, or 16.
Preallocating multiple hash buckets increases the speed of adding and finding elements. If each hash bucket is stored in a separate container, preallocating hash buckets also reduces the chance of lock conflicts. However, an unordered set with a large number of initial hash buckets requires more disk space, more memory for the directory, and more time to create.
adminContainer
- The container in
which to store the hash administrator for the new unordered
set; specify null to store the hash administrator in a newly
created container. bucketContainer
- The container in
which to store the initial hash buckets for the new unordered
set; specify null to store each initial hash bucket in its
own newly created container.public ooHashSet(ooCompare compare, int bucketSize, int initialBuckets, ooContObj adminContainer, ooContObj bucketContainer)
compare
- The comparator for the new set; must be
an instance of an application-specific subclass of
ooCompare.bucketSize
- The size of a hash bucket
in the new unordered set's hash table. The size of
a hash bucket is the number of elements that can be hashed into each
bucket. For optimal performance, the bucket size should be a prime
number. If you specify a bucket size that is not a prime number, the
next higher prime number is computed and used as the actual bucket
size.initialBuckets
- The minimum number of
initial hash buckets to create for the new unordered set. The
actual number of hash buckets created is the smallest power of 2 that
is greater than initialBuckets. For example, if
initialBuckets is 10, the number of initial hash
buckets is 2**4, or 16.
Preallocating multiple hash buckets increases the speed of adding and finding elements. If each hash bucket is stored in a separate container, preallocating hash buckets also reduces the chance of lock conflicts. However, an unordered set with a large number of initial hash buckets requires more disk space, more memory for the directory, and more time to create.
adminContainer
- The container in
which to store the hash administrator for the new unordered
set; specify null to store the hash administrator in a newly
created container. bucketContainer
- The container in
which to store the initial hash buckets for the new unordered
set; specify null to store each initial hash bucket in its
own newly created container.Method Detail |
public boolean addAll(Collection collection)
addAll
in interface Set
collection
- The collection
whose elements are to be added to this unordered set. Every element
of collection must be an instance of a
persistence-capable class. If any element is transient, this
method makes it persistent.This method returns false if this unordered set already contains all the elements of collection.
public boolean containsAll(Collection collection)
containsAll
in interface Set
collection
- The collection whose elements are
to be tested for containment in this unordered set.public Object get(Object lookupValue)
Note: This unordered set must have an application-defined comparator that can identify an element based on class-specific data. See Defining a Comparator Class for Unordered Collections.
lookupValue
- The object that identifies
the desired element.public Iterator iterator()
iterator
in interface Set
If you want to call any methods that are specific to Objectivity
for Java collection iterators, you should cast the returned iterator
to ooCollectionIterator
.
public void maxBucketsPerContainer(int max)
max
- The maximum number of
hash buckets for this unordered set that can be stored in a single
container.public boolean ooRemove(Object object)
This method is equivalent to remove
.
ooRemove
in class ooCollection
object
- The object to be removed.public boolean remove(Object object)
remove
in interface Set
object
- The object to be removed.removeAll(java.util.Collection)
,
retainAll(java.util.Collection)
public boolean removeAll(Collection collection)
removeAll
in interface Set
collection
- The collection whose elements are to be
removed from this unordered set.remove(java.lang.Object)
,
retainAll(java.util.Collection)
public boolean retainAll(Collection collection)
retainAll
in interface Set
collection
- The collection whose elements
are to be retained in this unordered set.remove(java.lang.Object)
,
removeAll(java.util.Collection)
|
Objectivity for Java Reference | |||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright © 2000 Objectivity, Inc. All rights reserved.