T
- the type of the field elementspublic class FieldArrayDictionary<T extends CalculusFieldElement<T>> extends Object
This class is a low overhead for a very small number of keys.
It is based on simple array and string comparison. It plays
the same role a Map<String, T[]>
but with reduced
features and not intended for large number of keys. For such
needs the regular Map<String, T[]>
should be preferred.
Modifier and Type | Class and Description |
---|---|
class |
FieldArrayDictionary.Entry
Entry in a dictionary.
|
Constructor and Description |
---|
FieldArrayDictionary(Field<T> field)
Constructor with
default initial capacity . |
FieldArrayDictionary(Field<T> field,
int initialCapacity)
Constructor with specified capacity.
|
FieldArrayDictionary(Field<T> field,
Map<String,T[]> map)
Constructor from a map.
|
FieldArrayDictionary(FieldArrayDictionary<T> dictionary)
Constructor from another dictionary.
|
Modifier and Type | Method and Description |
---|---|
void |
clear()
Remove all entries.
|
T[] |
get(String key)
Get the value corresponding to a key.
|
List<FieldArrayDictionary.Entry> |
getData()
Get an unmodifiable view of the dictionary entries.
|
FieldArrayDictionary.Entry |
getEntry(String key)
Get a complete entry.
|
Field<T> |
getField()
Get the field to which elements belong.
|
void |
put(String key,
double[] value)
Add an entry.
|
void |
put(String key,
T[] value)
Add an entry.
|
void |
putAll(FieldArrayDictionary<T> dictionary)
Put all the entries from another dictionary.
|
void |
putAll(Map<String,T[]> map)
Put all the entries from the map in the dictionary.
|
boolean |
remove(String key)
remove an entry.
|
int |
size()
Get the number of dictionary entries.
|
Map<String,T[]> |
toMap()
Create a map from the instance.
|
String |
toString()
Get a string representation of the dictionary.
|
FieldArrayDictionary<T> |
unmodifiableView()
Get an unmodifiable view of the dictionary.
|
public FieldArrayDictionary(Field<T> field)
default initial capacity
.field
- field to which the elements belongpublic FieldArrayDictionary(Field<T> field, int initialCapacity)
field
- field to which the elements belonginitialCapacity
- initial capacitypublic FieldArrayDictionary(FieldArrayDictionary<T> dictionary)
dictionary
- dictionary to use for initializing entriespublic Field<T> getField()
public List<FieldArrayDictionary.Entry> getData()
public int size()
public Map<String,T[]> toMap()
The map contains a copy of the instance data
public void clear()
public void put(String key, T[] value)
If an entry with the same key already exists, it will be removed first.
The new entry is always put at the end.
key
- entry keyvalue
- entry valuepublic void put(String key, double[] value)
If an entry with the same key already exists, it will be removed first.
The new entry is always put at the end.
key
- entry keyvalue
- entry valuepublic void putAll(Map<String,T[]> map)
map
- map to copy into the instancepublic void putAll(FieldArrayDictionary<T> dictionary)
dictionary
- dictionary to copy into the instancepublic T[] get(String key)
key
- entry keypublic FieldArrayDictionary.Entry getEntry(String key)
key
- entry keypublic boolean remove(String key)
key
- key of the entry to removepublic FieldArrayDictionary<T> unmodifiableView()
The return dictionary is backed by the original instance and offers read-only
access to it, but all operations that modify it throw an UnsupportedOperationException
.
Copyright © 2002-2023 CS GROUP. All rights reserved.