public class DoubleArrayDictionary extends Object implements Serializable
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, double[]>
but with reduced
features and not intended for large number of keys. For such
needs the regular Map<String, double[]>
should be preferred.
Modifier and Type | Class and Description |
---|---|
static class |
DoubleArrayDictionary.Entry
Entry in a dictionary.
|
Constructor and Description |
---|
DoubleArrayDictionary()
Constructor with
default initial capacity . |
DoubleArrayDictionary(DoubleArrayDictionary dictionary)
Constructor from another dictionary.
|
DoubleArrayDictionary(int initialCapacity)
Constructor with specified capacity.
|
DoubleArrayDictionary(Map<String,double[]> map)
Constructor from a map.
|
Modifier and Type | Method and Description |
---|---|
void |
clear()
Remove all entries.
|
double[] |
get(String key)
Get the value corresponding to a key.
|
List<DoubleArrayDictionary.Entry> |
getData()
Get an unmodifiable view of the dictionary entries.
|
DoubleArrayDictionary.Entry |
getEntry(String key)
Get a complete entry.
|
void |
put(String key,
double[] value)
Add an entry.
|
void |
putAll(DoubleArrayDictionary dictionary)
Put all the entries from another dictionary.
|
void |
putAll(Map<String,double[]> 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,double[]> |
toMap()
Create a map from the instance.
|
String |
toString()
Get a string representation of the dictionary.
|
DoubleArrayDictionary |
unmodifiableView()
Get an unmodifiable view of the dictionary.
|
public DoubleArrayDictionary()
default initial capacity
.public DoubleArrayDictionary(int initialCapacity)
initialCapacity
- initial capacitypublic DoubleArrayDictionary(DoubleArrayDictionary dictionary)
dictionary
- dictionary to use for initializing entriespublic List<DoubleArrayDictionary.Entry> getData()
public int size()
public Map<String,double[]> toMap()
The map contains a copy of the instance data
public void clear()
public 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,double[]> map)
map
- map to copy into the instancepublic void putAll(DoubleArrayDictionary dictionary)
dictionary
- dictionary to copy into the instancepublic double[] get(String key)
key
- entry keypublic DoubleArrayDictionary.Entry getEntry(String key)
key
- entry keypublic boolean remove(String key)
key
- key of the entry to removepublic DoubleArrayDictionary 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-2022 CS GROUP. All rights reserved.