| java.lang.Object | |||
| ↳ | java.util.AbstractMap<K, V> | ||
| ↳ | java.util.TreeMap<K, V> | ||
| ↳ | com.pnfsoftware.jeb.util.collect.SegmentMap<K extends java.lang.Comparable<K>, V extends com.pnfsoftware.jeb.util.collect.ISegment<K>> | ||
Standard implementation of a segment-map using a TreeMap as the underlying data structure. Supports auto-removal of values when inserting a new segment overlaps exisiting segments.
This class is not thread-safe.
| Public Constructors | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
|
SegmentMap()
Create a segment-map that uses natural comparison for the keys.
| |||||||||||
| Protected Constructors | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
|
SegmentMap(Comparator<? super K> comparator)
Create a segment-map using the provided key comparator.
| |||||||||||
| Public Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| V |
add(V v)
Add a segment to the map.
| ||||||||||
| int |
compareKeys(K a, K b)
Compare two keys using the map's actual comparator.
| ||||||||||
| SortedMap<K, V> |
contiguousSubMap(K begin, K end, ISegmentFactory<K, V> factory)
Get a map containing all the segments in the ranges, without any gap.
| ||||||||||
| boolean | equals(Object obj) | ||||||||||
| List<V> |
fillGaps(K begin, K end, ISegmentFactory<K, V> factory)
Create segments to fill in the gaps in the provided range of addresses.
| ||||||||||
| List<V> |
generateGapItems(K begin, boolean allowHeader, K end, boolean allowTrailer, ISegmentFactory<K, V> factory, boolean addItemsToMap)
Create segments to fill in the gaps in the provided range of addresses.
| ||||||||||
| SortedMap<K, V> |
getOverlappingSegmentsMap(K begin, boolean includeFirstPartialSegment, K end, boolean includeLastPartialSegment)
Get all segments partially or fully present in the given range.
| ||||||||||
| V |
getSegmentAfter(K key)
Get the closest segment after the provided address, which does not contain it.
| ||||||||||
| V |
getSegmentBefore(K key)
Get the closest segment before the provided address, which does not contain it.
| ||||||||||
| V |
getSegmentContaining(K key)
Get the segment containing the provided address.
| ||||||||||
| int | hashCode() | ||||||||||
| boolean |
isEmptyRange(K begin, K end)
Determine is the provided range is unencumbered.
| ||||||||||
| boolean |
isRemoveSegmentsOnOverlap()
Get the map behavior when the insertion of a segment would overlap existing segments.
| ||||||||||
| boolean |
isValidKey(K k)
Validate whether or not the provided key is valid.
| ||||||||||
| boolean |
isValidSegment(V v)
Validate whether or not the provided key is valid.
| ||||||||||
| V | put(K k, V v) | ||||||||||
| void | putAll(Map<? extends K, ? extends V> m) | ||||||||||
| void |
setRemoveSegmentsOnOverlap(boolean removeSegmentsOnOverlap)
Set the map behavior when the insertion of a segment would overlap existing segments.
| ||||||||||
| String | toString() | ||||||||||
|
[Expand]
Inherited Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.util.TreeMap
| |||||||||||
From class
java.util.AbstractMap
| |||||||||||
From class
java.lang.Object
| |||||||||||
From interface
com.pnfsoftware.jeb.util.collect.ISegmentMap
| |||||||||||
From interface
java.util.Map
| |||||||||||
From interface
java.util.NavigableMap
| |||||||||||
From interface
java.util.SortedMap
| |||||||||||
Create a segment-map that uses natural comparison for the keys.
Create a segment-map using the provided key comparator.
| comparator | a custom comparator for the keys |
|---|
Add a segment to the map. Convenience method, similar to put.
Compare two keys using the map's actual comparator.
Get a map containing all the segments in the ranges, without any gap. Unlike
subMap, the map returned by this method is not a "view" of
the original map; modifying this map, such as inserting or deleting items, does not modify
the original map. The original segment-map is not modified; that is, if gap items, are
created, they are not added to the original map.
| begin | start address, inclusive. The first item should start at or after this address; any item simply containing (ie, spanning over) the start address will not be part of the resulting map. |
|---|---|
| end | end address end address, exclusive |
| factory | a factory used to generate gap items |
Create segments to fill in the gaps in the provided range of addresses. Trailer and header gaps will be created if need be.
| begin | begin address |
|---|---|
| end | end address |
| factory | a factory object used to create segments |
Create segments to fill in the gaps in the provided range of addresses.
| begin | begin address |
|---|---|
| allowHeader | determine if an unbounded gap header can be filled |
| end | end address |
| allowTrailer | determine if an unbounded gap trailer can be filled |
| factory | a factory object used to create segments |
| addItemsToMap | if true, the items created to fill in the gaps in the segment map are also added to the segment map |
Get all segments partially or fully present in the given range. The returned map is not a view of the original map. Modifying it will not modify the original map.
Get the closest segment after the provided address, which does not contain it.
| key | address to probe |
|---|
Get the closest segment before the provided address, which does not contain it.
| key | address to probe |
|---|
Get the segment containing the provided address.
| key | address to probe |
|---|
Determine is the provided range is unencumbered.
| begin | inclusive start address |
|---|---|
| end | exclusive end address |
Get the map behavior when the insertion of a segment would overlap existing segments.
Validate whether or not the provided key is valid. The default implementation simply returns true: all objects of type K are valid keys, as would be expected by an implementation of Map.
This method is called when attempting to insert an entry into a map (using
add, put, or putall).
| k | a key |
|---|
Set the map behavior when the insertion of a segment would overlap existing segments.