public class RegionMap<V> extends OrderedMap<short[],V> implements java.io.Serializable
short[]
regions as produced by CoordPacker
.
The methods allAt(int, int)
, containsRegion(short[])
, and regionsContaining(int, int)
are
added here, and the minor extra work needed to handle array keys in OrderedMap is taken care of automatically.
toString()
also produces nicer output by default for this usage, with the keys printed in a usable way.
Created by Tommy Ettinger on 11/24/2016.OrderedMap.KeyIterator, OrderedMap.KeySet, OrderedMap.MapEntrySet, OrderedMap.ValueCollection, OrderedMap.ValueIterator
containsNullKey, DEFAULT_INITIAL_SIZE, DEFAULT_LOAD_FACTOR, defRetValue, entries, f, FAST_LOAD_FACTOR, hasher, key, keys, mask, maxFill, n, order, size, value, values, VERY_FAST_LOAD_FACTOR
Constructor and Description |
---|
RegionMap()
Creates a new RegionMap with initial expected 16 entries and 0.75f as load factor.
|
RegionMap(java.util.Collection<short[]> keyColl,
java.util.Collection<V> valueColl,
float f)
Creates a new RegionMap using the elements of two parallel arrays.
|
RegionMap(int expected)
Creates a new RegionMap with 0.75f as load factor.
|
RegionMap(int expected,
float f) |
RegionMap(java.util.Map<short[],? extends V> m)
Creates a new RegionMap with 0.75f as load factor copying a given one.
|
RegionMap(java.util.Map<short[],? extends V> m,
float f)
Creates a new RegionMap copying a given one.
|
RegionMap(short[][] keyArray,
V[] valueArray)
Creates a new RegionMap with 0.75f as load factor using the elements of two parallel arrays.
|
RegionMap(short[][] keyArray,
V[] valueArray,
float f)
Creates a new RegionMap using the elements of two parallel arrays.
|
Modifier and Type | Method and Description |
---|---|
java.util.ArrayList<V> |
allAt(int x,
int y)
Gets a List of all values associated with regions containing a given x,y point.
|
boolean |
containsRegion(short[] region)
Checks if a region, stored as packed data (possibly from CoordPacker or this class) overlaps with regions stored
in this object as keys.
|
OrderedSet<short[]> |
regionsContaining(int x,
int y)
Gets a List of all regions containing a given x,y point.
|
java.lang.String |
toString() |
java.lang.String |
toString(java.lang.String separator) |
alter, alterAt, alterAtCarefully, alterCarefully, arraySize, clear, clone, comparator, containsKey, containsValue, defaultReturnValue, defaultReturnValue, ensureCapacity, entryAt, entrySet, equals, firstKey, fixOrder, fixOrder, get, getAndMoveToFirst, getAndMoveToLast, getAt, getMany, getOrDefault, hash64, hashCode, headMap, indexOf, isEmpty, keyAt, keysAsOrderedSet, keySet, lastKey, makeMap, makeMap, maxFill, objectUnwrap, objectUnwrap, positionOf, put, putAll, putAll, putAndMoveToFirst, putAndMoveToLast, putAt, putIfAbsent, putPairs, randomEntry, randomKey, randomValue, rehash, remove, remove, removeAt, removeEntry, removeFirst, removeLast, removeNullEntry, reorder, replace, replace, reverse, setAt, shiftKeys, shuffle, size, sort, sort, sortByValue, sortByValue, subMap, swap, swapIndices, tailMap, trim, trim, unwrap, unwrap, values, valuesAsList
public RegionMap(int expected, float f)
public RegionMap(int expected)
expected
- the expected number of elements in the RegionMap.public RegionMap()
public RegionMap(java.util.Map<short[],? extends V> m, float f)
m
- a Map
to be copied into the new RegionMap.f
- the load factor.public RegionMap(java.util.Map<short[],? extends V> m)
m
- a Map
to be copied into the new RegionMap.public RegionMap(short[][] keyArray, V[] valueArray, float f)
keyArray
- the array of keys of the new RegionMap.valueArray
- the array of corresponding values in the new RegionMap.f
- the load factor.java.lang.IllegalArgumentException
- if k
and v
have different lengths.public RegionMap(java.util.Collection<short[]> keyColl, java.util.Collection<V> valueColl, float f)
keyColl
- the collection of keys of the new RegionMap.valueColl
- the collection of corresponding values in the new RegionMap.f
- the load factor.java.lang.IllegalArgumentException
- if k
and v
have different lengths.public RegionMap(short[][] keyArray, V[] valueArray)
keyArray
- the array of keys of the new RegionMap.valueArray
- the array of corresponding values in the new RegionMap.java.lang.IllegalArgumentException
- if k
and v
have different lengths.public java.util.ArrayList<V> allAt(int x, int y)
x
- the x coordinate of the point in questiony
- the y coordinate of the point in questionpublic boolean containsRegion(short[] region)
region
- the packed region to check for overlap with regions this stores values forpublic OrderedSet<short[]> regionsContaining(int x, int y)
x
- the x coordinate of the point in questiony
- the y coordinate of the point in questionpublic java.lang.String toString(java.lang.String separator)
public java.lang.String toString()
toString
in class OrderedMap<short[],V>
Copyright © Eben Howard 2012–2022. All rights reserved.