Package org.simpleframework.xml.util
Class WeakCache.SegmentList
java.lang.Object
org.simpleframework.xml.util.WeakCache.SegmentList
This is used to maintain a list of segments. All segments that
are stored by this object can be acquired using a given key.
The keys hash is used to select the segment, this ensures that
all read and write operations with the same key result in the
same segment object within this list.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate void
create
(int size) Upon initialization the segment list is populated in such a way that synchronization is not needed.This is used to acquire the segment using the given key.iterator()
private int
This method performs the translation of the key hash code to the segment index within the list.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
list
The list of segment objects maintained by this object. -
size
private int sizeRepresents the number of segments this object maintains.
-
-
Constructor Details
-
SegmentList
public SegmentList(int size) Constructor for theSegmentList
object. This is used to create a list of weak hash maps that can be acquired using the hash code of a given key.- Parameters:
size
- this is the number of hash maps to maintain
-
-
Method Details
-
iterator
-
get
This is used to acquire the segment using the given key. The keys hash is used to determine the index within the list to acquire the segment, which is a synchronized weak hash map storing the key value pairs for a given hash.- Parameters:
key
- this is the key used to determine the segment- Returns:
- the segment that is stored at the resolved hash
-
create
private void create(int size) Upon initialization the segment list is populated in such a way that synchronization is not needed. Each segment is created and stored in an increasing index within the list.- Parameters:
size
- this is the number of segments to be used
-
segment
This method performs the translation of the key hash code to the segment index within the list. Translation is done by acquiring the modulus of the hash and the list size.- Parameters:
key
- this is the key used to resolve the index- Returns:
- the index of the segment within the list
-