public final class WeightedSet<K extends FieldValue> extends CollectionFieldValue<K> implements Map<K,Integer>
Modifier and Type | Class and Description |
---|---|
(package private) class |
WeightedSet.WeightedSetWrapper
Weighted set MapFieldValue, backed by map of native Java types.
|
FieldValue.RecursiveIteratorHandler
Modifier and Type | Field and Description |
---|---|
private MapFieldValue<K,IntegerFieldValue> |
map |
classId
Constructor and Description |
---|
WeightedSet(DataType type)
Creates a new WeightedSet.
|
WeightedSet(DataType type,
int initialCapacity)
Creates a new weighted set with a given initial capacity.
|
Modifier and Type | Method and Description |
---|---|
boolean |
add(K value) |
void |
assign(Object o)
Assign this non-fieldvalue value to this field value.
|
void |
clear()
Remove all key-weight associations in this set.
|
void |
clearAndReserve(int count)
Reserve space for this amount of keys in order to avoid resizing
|
WeightedSet |
clone() |
int |
compareTo(FieldValue fieldValue) |
boolean |
contains(Object o) |
boolean |
containsKey(Object key)
Checks whether this set contains the specified key.
|
boolean |
containsValue(Object value) |
void |
deserialize(Field field,
FieldReader reader)
Read a field value from the specified reader
|
Set<Map.Entry<K,Integer>> |
entrySet() |
boolean |
equals(Object o)
Checks if another object is equal to this set.
|
Iterator<K> |
fieldValueIterator() |
Integer |
get(Object key)
Returns the weight associated with the specified key.
|
WeightedSetDataType |
getDataType() |
(package private) Map<K,Integer> |
getPrimitiveMap() |
Object |
getWrappedValue()
Used to retrieve wrapped type for simple types, such that you can use get methods to retrieve ints and floats
directly instead of Int/Float field values.
|
int |
hashCode()
Uses hashCode() from the encapsulated Map.
|
boolean |
isEmpty()
Checks if this set is empty.
|
(package private) FieldPathIteratorHandler.ModificationStatus |
iterateNested(FieldPath fieldPath,
int pos,
FieldPathIteratorHandler handler)
Iterates through the document using the given fieldpath, calling callbacks in the given iterator
handler.
|
Iterator<K> |
iterator() |
Set<K> |
keySet() |
void |
printXml(XmlStream xml) |
Integer |
put(K key,
Integer weight)
Add a key with an associated weight to this set.
|
void |
putAll(Map<? extends K,? extends Integer> t) |
IntegerFieldValue |
putUnChecked(K key,
IntegerFieldValue weight)
Add a key with an associated weight to this set.
|
Integer |
remove(Object key)
Remove a key-weight association from this set.
|
boolean |
removeValue(FieldValue o) |
void |
serialize(Field field,
FieldWriter writer)
Write out field value to the specified writer
|
int |
size()
Returns the number of key-weight pairs in this set.
|
String |
toString()
Uses toString() from the encapsulated Map.
|
Collection<Integer> |
values() |
createFieldValue, isEmpty, removeValue, verifyElementCompatibility
setDataType
checkAssign, create, deserialize, getRecursiveValue, getRecursiveValue, onDeserialize, onSerialize, serialize, toXml
create, createFromId, deserialize, deserializeOptional, deserializeWithId, equals, getClassId, getUtf8, onGetClassId, putUtf8, registerClass, serialize, serializeOptional, serializeWithId, visitMembers
finalize, getClass, notify, notifyAll, wait, wait, wait
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
private MapFieldValue<K extends FieldValue,IntegerFieldValue> map
public WeightedSet(DataType type)
type
- the data type for the field that this weighted set is associated withpublic WeightedSet(DataType type, int initialCapacity)
initialCapacity
- the initial capacity to use for the encapsulated Mappublic WeightedSetDataType getDataType()
getDataType
in class CollectionFieldValue<K extends FieldValue>
public Iterator<K> fieldValueIterator()
fieldValueIterator
in class CollectionFieldValue<K extends FieldValue>
public void assign(Object o)
FieldValue
Override to accept the specific types that should be legal.
assign
in class FieldValue
public WeightedSet clone()
clone
in class FieldValue
public void printXml(XmlStream xml)
printXml
in class FieldValue
public int size()
size
in interface Map<K extends FieldValue,Integer>
size
in class CollectionFieldValue<K extends FieldValue>
public boolean add(K value)
add
in class CollectionFieldValue<K extends FieldValue>
public Object getWrappedValue()
FieldValue
getWrappedValue
in class FieldValue
public boolean contains(Object o)
contains
in class CollectionFieldValue<K extends FieldValue>
public boolean isEmpty()
isEmpty
in interface Map<K extends FieldValue,Integer>
isEmpty
in class CollectionFieldValue<K extends FieldValue>
public Iterator<K> iterator()
iterator
in class CollectionFieldValue<K extends FieldValue>
public boolean removeValue(FieldValue o)
removeValue
in class CollectionFieldValue<K extends FieldValue>
public boolean containsKey(Object key)
containsKey
in interface Map<K extends FieldValue,Integer>
key
- the key to search forpublic boolean containsValue(Object value)
containsValue
in interface Map<K extends FieldValue,Integer>
public Integer get(Object key)
get
in interface Map<K extends FieldValue,Integer>
key
- the key to return the weight forpublic Integer put(K key, Integer weight)
put
in interface Map<K extends FieldValue,Integer>
key
- the key to addweight
- the weight to associate with this keypublic IntegerFieldValue putUnChecked(K key, IntegerFieldValue weight)
key
- the key to addweight
- the weight to associate with this keypublic Integer remove(Object key)
remove
in interface Map<K extends FieldValue,Integer>
key
- the key to removepublic void putAll(Map<? extends K,? extends Integer> t)
putAll
in interface Map<K extends FieldValue,Integer>
public void clear()
clear
in interface Map<K extends FieldValue,Integer>
clear
in class FieldValue
public void clearAndReserve(int count)
public Collection<Integer> values()
values
in interface Map<K extends FieldValue,Integer>
public Set<Map.Entry<K,Integer>> entrySet()
entrySet
in interface Map<K extends FieldValue,Integer>
public boolean equals(Object o)
equals
in interface Map<K extends FieldValue,Integer>
equals
in class CompositeFieldValue
o
- the object to check for equality withpublic int hashCode()
hashCode
in interface Map<K extends FieldValue,Integer>
hashCode
in class CompositeFieldValue
public String toString()
toString
in class com.yahoo.vespa.objects.Identifiable
public void serialize(Field field, FieldWriter writer)
FieldValue
serialize
in class FieldValue
public void deserialize(Field field, FieldReader reader)
FieldValue
deserialize
in class FieldValue
FieldPathIteratorHandler.ModificationStatus iterateNested(FieldPath fieldPath, int pos, FieldPathIteratorHandler handler)
FieldValue
iterateNested
in class FieldValue
public int compareTo(FieldValue fieldValue)
compareTo
in interface Comparable<FieldValue>
compareTo
in class FieldValue
Copyright © 2017. All rights reserved.