public class ImmutableFeatureMap extends FeatureMap implements Serializable
It's also got feature ids as those are only generated for immutable maps.
The feature ids are generated by sorting the feature names by the String comparator.
This ensures that any Example with sorted names has sorted int ids, even if some of
those features are unobserved. This is an extremely important property of Feature
s,
Example
s and ImmutableFeatureMap
.
Modifier and Type | Field and Description |
---|---|
protected Map<Integer,VariableIDInfo> |
idMap
The map from id numbers to the feature infos.
|
protected int |
size
The number of features.
|
m
Modifier | Constructor and Description |
---|---|
protected |
ImmutableFeatureMap()
Constructs a new empty immutable feature map.
|
|
ImmutableFeatureMap(FeatureMap map)
Constructs a new immutable version which is a deep copy of the supplied feature map, generating new ID numbers.
|
|
ImmutableFeatureMap(List<VariableInfo> infoList)
Constructs a new immutable feature map copying the supplied variable infos and generating appropriate ID numbers.
|
Modifier and Type | Method and Description |
---|---|
static Map<String,VariableIDInfo> |
generateIDs(FeatureMap map)
Generates the feature ids by sorting the features with the String comparator,
then sequentially numbering them.
|
static Map<String,VariableIDInfo> |
generateIDs(List<? extends VariableInfo> list)
Generates the feature ids by sorting the features with the String comparator,
then sequentially numbering them.
|
VariableIDInfo |
get(int id)
Gets the
VariableIDInfo
for this id number. |
VariableIDInfo |
get(String name)
Gets the
VariableIDInfo
for this name. |
int |
getID(String name)
Gets the id number for this feature, returns -1 if it's unknown.
|
int |
size()
Returns the number of features in the domain.
|
iterator, keySet, toReadableString, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
forEach, spliterator
protected final Map<Integer,VariableIDInfo> idMap
protected int size
public ImmutableFeatureMap(FeatureMap map)
The new id numbers will be the same as the old ones (if they existed) assuming this is a regular feature map.
map
- The map to copy.public ImmutableFeatureMap(List<VariableInfo> infoList)
infoList
- The variable infos.protected ImmutableFeatureMap()
Used for mocking feature domains in tests.
public VariableIDInfo get(int id)
VariableIDInfo
for this id number. Returns null if it's unknown.id
- The id number to lookup.public VariableIDInfo get(String name)
VariableIDInfo
for this name. Returns null if it's unknown.get
in class FeatureMap
name
- The name to lookup.public int getID(String name)
name
- The name of the feature.public int size()
FeatureMap
size
in class FeatureMap
public static Map<String,VariableIDInfo> generateIDs(FeatureMap map)
map
- A feature map to convert.public static Map<String,VariableIDInfo> generateIDs(List<? extends VariableInfo> list)
list
- A list of VariableInfo
s to generate a map from.Copyright © 2015–2021 Oracle and/or its affiliates. All rights reserved.