K
- the type of the key elementsV
- the type of the value elementspublic final class RubyHash<K,V> extends RubyEnumerable<java.util.Map.Entry<K,V>> implements java.util.Map<K,V>, java.io.Serializable
RubyHash
implements all methods refer to the Hash class of Ruby
language.
RubyHash
is also a Java Map and a Ruby.Enumerable
.
Constructor and Description |
---|
RubyHash()
Creates a
RubyHash . |
RubyHash(java.util.LinkedHashMap<K,V> map)
Creates a
RubyHash by given LinkedHashMap. |
RubyHash(java.util.Map<K,V> map)
Creates a
RubyHash by given Map. |
Modifier and Type | Method and Description |
---|---|
boolean |
allʔ(EntryBooleanBlock<? super K,? super V> block)
An adapter method.
|
boolean |
anyʔ(EntryBooleanBlock<? super K,? super V> block)
An adapter method.
|
java.util.Map.Entry<K,V> |
assoc(K key)
Finds an Entry by given key.
|
<S> RubyEnumerator<java.util.Map.Entry<S,RubyArray<java.util.Map.Entry<K,V>>>> |
chunk(EntryTransformBlock<? super K,? super V,? extends S> block)
An adapter method.
|
void |
clear() |
<S> RubyArray<S> |
collect(EntryTransformBlock<? super K,? super V,? extends S> block)
An adapter method.
|
<S> RubyArray<S> |
collectConcat(EntryTransformBlock<? super K,? super V,? extends java.util.List<S>> block)
An adapter method.
|
RubyHash<K,V> |
compareByIdentity()
Turns this
RubyHash to compare each elements by their identities
instead of their equalities. |
boolean |
comparedByIdentityʔ()
Returns whether this
RubyHash is compared by identity. |
boolean |
containsKey(java.lang.Object key) |
boolean |
containsValue(java.lang.Object value) |
static <K,V> RubyHash<K,V> |
copyOf(java.util.Map<K,V> map)
Returns a
RubyHash which copies the elements of given Map. |
int |
count(EntryBooleanBlock<? super K,? super V> block)
An adapter method.
|
void |
cycle(EntryBlock<? super K,? super V> block)
An adapter method.
|
void |
cycle(int n,
EntryBlock<? super K,? super V> block)
An adapter method.
|
V |
delete(K key)
Deletes an Entry by given key and returns the deleted value.Returns null if
key is not found and default value is not set.
|
RubyEnumerator<java.util.Map.Entry<K,V>> |
deleteIf()
Returns a
RubyEnumerator of entries this RubyHash . |
RubyHash<K,V> |
deleteIf(EntryBooleanBlock<? super K,? super V> block)
Deletes entries which the result are true returned by the block.
|
java.util.Map.Entry<K,V> |
detect(EntryBooleanBlock<? super K,? super V> block)
An adapter method.
|
RubyArray<java.util.Map.Entry<K,V>> |
dropWhile(EntryBooleanBlock<? super K,? super V> block)
An adapter method.
|
RubyHash<K,V> |
each(EntryBlock<? super K,? super V> block) |
RubyEnumerable<java.util.Map.Entry<K,V>> |
eachEntry(EntryBlock<? super K,? super V> block)
An adapter method.
|
RubyEnumerator<K> |
eachKey()
Returns a
RubyEnumerator of keys of this RubyHash . |
RubyHash<K,V> |
eachKey(Block<? super K> block)
Yields each key to given block.
|
RubyEnumerator<java.util.Map.Entry<K,V>> |
eachPair()
Returns a
RubyEnumerator of entries this RubyHash . |
RubyHash<K,V> |
eachPair(EntryBlock<? super K,? super V> block)
Equivalent to
each(EntryBlock) . |
RubyEnumerator<V> |
eachValue()
Returns a
RubyEnumerator of values of this RubyHash . |
RubyHash<K,V> |
eachValue(Block<? super V> block)
Yields each value to given block.
|
boolean |
emptyʔ()
Checks if this
RubyHash is empty. |
java.util.Set<java.util.Map.Entry<K,V>> |
entrySet() |
boolean |
eqlʔ(java.lang.Object other)
Equivalent to
equals(Object) . |
boolean |
equals(java.lang.Object o) |
V |
fetch(K key)
Fetchs the value of the key.
|
V |
fetch(K key,
V defaultValue)
Fetches the value of the key.
|
java.util.Map.Entry<K,V> |
find(EntryBooleanBlock<? super K,? super V> block)
An adapter method.
|
RubyArray<java.util.Map.Entry<K,V>> |
findAll(EntryBooleanBlock<? super K,? super V> block)
An adapter method.
|
java.lang.Integer |
findIndex(EntryBooleanBlock<? super K,? super V> block)
An adapter method.
|
<S> RubyArray<S> |
flatMap(EntryTransformBlock<? super K,? super V,? extends java.util.List<S>> block)
An adapter method.
|
RubyArray<java.util.Map.Entry<K,V>> |
flatten()
Returns a
RubyEnumerator of entries of this RubyHash . |
RubyHash<K,V> |
freeze()
Freezes this
RubyHash . |
boolean |
frozenʔ()
Checks if this
RubyHash is frozen. |
V |
get(java.lang.Object key) |
V |
getDefault()
Returns the default value of this
RubyHash . |
protected java.lang.Iterable<java.util.Map.Entry<K,V>> |
getIterable()
Returns an Iterable of elements.
|
<S> RubyArray<S> |
grep(java.lang.String regex,
EntryTransformBlock<? super K,? super V,? extends S> block)
An adapter method.
|
<S> RubyHash<S,RubyArray<java.util.Map.Entry<K,V>>> |
groupBy(EntryTransformBlock<? super K,? super V,? extends S> block)
An adapter method.
|
int |
hash()
Equivalent to
hashCode() . |
int |
hashCode() |
java.lang.String |
inspect()
Equivalent to
toString() . |
RubyHash<V,K> |
invert()
|
boolean |
isEmpty() |
RubyEnumerator<java.util.Map.Entry<K,V>> |
keepIf()
Returns a
RubyEnumerator of entries of this RubyHash . |
RubyHash<K,V> |
keepIf(EntryBooleanBlock<? super K,? super V> block)
Keeps elements which the result are true returned by the block.
|
K |
key(V value)
Finds the key related to given value.
|
RubyArray<K> |
keys()
|
java.util.Set<K> |
keySet() |
boolean |
keyʔ(K key)
Equivalent to
containsKey(Object) . |
int |
length()
Equivalent to
size() . |
<S> RubyArray<S> |
map(EntryTransformBlock<? super K,? super V,? extends S> block)
An adapter method.
|
<S> java.util.Map.Entry<K,V> |
maxBy(java.util.Comparator<? super S> comp,
EntryTransformBlock<? super K,? super V,? extends S> block)
An adapter method.
|
<S> java.util.Map.Entry<K,V> |
maxBy(EntryTransformBlock<? super K,? super V,? extends S> block)
An adapter method.
|
RubyHash<K,V> |
merge(java.util.Map<? extends K,? extends V> otherHash)
Merges any Map with self and puts into a new
RubyHash . |
RubyHash<K,V> |
merge(java.util.Map<K,V> otherHash,
EntryMergeBlock<? super K,V> block)
Merges any Map with self and puts into a new
RubyHash . |
RubyHash<K,V> |
mergeǃ(java.util.Map<? extends K,? extends V> otherHash)
Merges any Map into self.
|
RubyHash<K,V> |
mergeǃ(java.util.Map<? extends K,? extends V> otherHash,
EntryMergeBlock<? super K,V> block)
Merges any Map into self.
|
<S> java.util.Map.Entry<K,V> |
minBy(java.util.Comparator<? super S> comp,
EntryTransformBlock<? super K,? super V,? extends S> block)
An adapter method.
|
<S> java.util.Map.Entry<K,V> |
minBy(EntryTransformBlock<? super K,? super V,? extends S> block)
An adapter method.
|
<S> RubyArray<java.util.Map.Entry<K,V>> |
minmaxBy(java.util.Comparator<? super S> comp,
EntryTransformBlock<? super K,? super V,? extends S> block)
An adapter method.
|
<S> RubyArray<java.util.Map.Entry<K,V>> |
minmaxBy(EntryTransformBlock<? super K,? super V,? extends S> block)
An adapter method.
|
boolean |
noneʔ(EntryBooleanBlock<? super K,? super V> block)
An adapter method.
|
static <K,V> RubyHash<K,V> |
of(java.util.LinkedHashMap<K,V> map)
Returns a
RubyHash which wraps the given Map. |
boolean |
oneʔ(EntryBooleanBlock<? super K,? super V> block)
An adapter method.
|
RubyArray<RubyArray<java.util.Map.Entry<K,V>>> |
partition(EntryBooleanBlock<? super K,? super V> block)
An adapter method.
|
V |
put(K key,
V value) |
RubyHash<K,V> |
put(java.util.Map.Entry<? extends K,? extends V>... entries)
Puts entries into this
RubyHash directly. |
RubyHash<K,V> |
put(java.util.Map.Entry<? extends K,? extends V> entry)
Puts an Entry into this
RubyHash directly. |
void |
putAll(java.util.Map<? extends K,? extends V> m) |
java.util.Map.Entry<K,V> |
rassoc(V value)
Finds an Entry by given value.
|
RubyArray<java.util.Map.Entry<K,V>> |
reject(EntryBooleanBlock<? super K,? super V> block)
An adapter method.
|
RubyEnumerator<java.util.Map.Entry<K,V>> |
rejectǃ()
Returns a
RubyEnumerator of entries of this RubyHash . |
RubyHash<K,V> |
rejectǃ(EntryBooleanBlock<? super K,? super V> block)
Deletes entries which are true returned by the block.
|
V |
remove(java.lang.Object key) |
RubyHash<K,V> |
replace(java.util.Map<? extends K,? extends V> otherHash)
Replaces all entries with the entries of given Map.
|
RubyEnumerable<java.util.Map.Entry<K,V>> |
reverseEach(EntryBlock<? super K,? super V> block)
An adapter method.
|
RubyArray<java.util.Map.Entry<K,V>> |
select(EntryBooleanBlock<? super K,? super V> block)
An adapter method.
|
V |
setDefault(V defaultValue)
Sets the default value of this
RubyHash . |
java.util.Map.Entry<K,V> |
shift()
Removes the first Entry and returns it.
|
int |
size() |
RubyEnumerator<RubyArray<java.util.Map.Entry<K,V>>> |
sliceBefore(EntryBooleanBlock<? super K,? super V> block)
An adapter method.
|
<S> RubyArray<java.util.Map.Entry<K,V>> |
sortBy(java.util.Comparator<? super S> comp,
EntryTransformBlock<? super K,? super V,? extends S> block)
An adapter method.
|
<S> RubyArray<java.util.Map.Entry<K,V>> |
sortBy(EntryTransformBlock<? super K,? super V,? extends S> block)
An adapter method.
|
V |
store(K key,
V value)
Puts a key-value pair and returns the value.
|
RubyArray<java.util.Map.Entry<K,V>> |
takeWhile(EntryBooleanBlock<? super K,? super V> block)
An adapter method.
|
RubyHash<K,V> |
toH()
Returns this
RubyHash . |
RubyHash<K,V> |
toHash()
Returns this
RubyHash . |
java.lang.String |
toS()
Equivalent to
toString() . |
java.lang.String |
toString() |
RubyHash<K,V> |
update(java.util.Map<? extends K,? extends V> otherHash)
Equivalent to
mergeǃ(Map) . |
RubyHash<K,V> |
update(java.util.Map<? extends K,? extends V> otherHash,
EntryMergeBlock<? super K,V> block)
Equivalent to
mergeǃ(Map, EntryMergeBlock) . |
RubyArray<V> |
values()
|
RubyArray<V> |
valuesAt(java.lang.Iterable<?> keys)
Finds all the values by given keys.
|
RubyArray<V> |
valuesAt(java.lang.Object... keys)
Finds all the values by given keys.
|
boolean |
valueʔ(java.lang.Object value)
Checks if the value included.
|
allʔ, allʔ, anyʔ, anyʔ, chunk, chunk, collect, collect, collect, collectConcat, collectConcat, count, count, cycle, cycle, cycle, cycle, detect, detect, drop, dropWhile, dropWhile, each, each, eachCons, eachCons, eachEntry, eachEntry, eachSlice, eachSlice, eachWithIndex, eachWithIndex, eachWithObject, eachWithObject, entries, find, find, findAll, findAll, findIndex, findIndex, findIndex, first, first, flatMap, flatMap, grep, grep, grep, groupBy, groupBy, groupBy, includeʔ, inject, inject, inject, inject, iterator, lazy, map, map, map, max, max, maxBy, maxBy, maxBy, maxBy, memberʔ, min, min, minBy, minBy, minBy, minBy, minmax, minmax, minmaxBy, minmaxBy, minmaxBy, minmaxBy, noneʔ, noneʔ, oneʔ, oneʔ, partition, partition, reduce, reduce, reduce, reduce, reject, reject, reverseEach, reverseEach, select, select, sliceBefore, sliceBefore, sort, sortBy, sortBy, sortBy, sortBy, sortBy, take, takeWhile, takeWhile, toA, zip, zip, zip
public RubyHash()
RubyHash
.public RubyHash(java.util.LinkedHashMap<K,V> map)
RubyHash
by given LinkedHashMap. It's a wrapper
implementation. No defensive copy has been made.map
- a LinkedHashMapjava.lang.NullPointerException
- if map is nullpublic static <K,V> RubyHash<K,V> of(java.util.LinkedHashMap<K,V> map)
RubyHash
which wraps the given Map.map
- any MapRubyHash
java.lang.NullPointerException
- if map is nullpublic static <K,V> RubyHash<K,V> copyOf(java.util.Map<K,V> map)
RubyHash
which copies the elements of given Map.map
- any MapRubyHash
java.lang.NullPointerException
- if map is nullprotected java.lang.Iterable<java.util.Map.Entry<K,V>> getIterable()
RubyEnumerable
getIterable
in class RubyEnumerable<java.util.Map.Entry<K,V>>
public java.util.Map.Entry<K,V> assoc(K key)
key
- to be foundpublic RubyHash<K,V> compareByIdentity()
RubyHash
to compare each elements by their identities
instead of their equalities.RubyHash
public boolean comparedByIdentityʔ()
RubyHash
is compared by identity.RubyHash
is compared by identity, false
otherwisepublic V delete(K key)
key
- to be deletedpublic RubyEnumerator<java.util.Map.Entry<K,V>> deleteIf()
RubyEnumerator
of entries this RubyHash
.RubyEnumerator
public RubyHash<K,V> deleteIf(EntryBooleanBlock<? super K,? super V> block)
block
- to filter elementsRubyHash
public V setDefault(V defaultValue)
RubyHash
.defaultValue
- default value if key is not foundpublic RubyHash<K,V> each(EntryBlock<? super K,? super V> block)
RubyHash
RubyEnumerable.each(Block)
public RubyEnumerator<K> eachKey()
RubyEnumerator
of keys of this RubyHash
.RubyEnumerator
public RubyHash<K,V> eachKey(Block<? super K> block)
block
- to yield each keyRubyHash
public RubyEnumerator<java.util.Map.Entry<K,V>> eachPair()
RubyEnumerator
of entries this RubyHash
.RubyEnumerator
public RubyHash<K,V> eachPair(EntryBlock<? super K,? super V> block)
each(EntryBlock)
.block
- to yield each entryRubyHash
public RubyEnumerator<V> eachValue()
RubyEnumerator
of values of this RubyHash
.RubyEnumerator
public RubyHash<K,V> eachValue(Block<? super V> block)
block
- to yield each valueRubyHash
public boolean emptyʔ()
RubyHash
is empty.RubyHash
is empty, false otherwisepublic boolean eqlʔ(java.lang.Object other)
equals(Object)
.other
- any Objectpublic V fetch(K key)
key
- to be foundjava.util.NoSuchElementException
- if key is not foundpublic V fetch(K key, V defaultValue)
key
- to be founddefaultValue
- when key is not foundpublic RubyArray<java.util.Map.Entry<K,V>> flatten()
RubyEnumerator
of entries of this RubyHash
.RubyEnumerator
public boolean frozenʔ()
RubyHash
is frozen.RubyHash
is frozen, false otherwisepublic int hash()
hashCode()
.public java.lang.String inspect()
toString()
.public RubyEnumerator<java.util.Map.Entry<K,V>> keepIf()
RubyEnumerator
of entries of this RubyHash
.RubyEnumerator
public RubyHash<K,V> keepIf(EntryBooleanBlock<? super K,? super V> block)
block
- to filter elementsRubyHash
public K key(V value)
value
- to be foundpublic boolean keyʔ(K key)
containsKey(Object)
.key
- to be foundpublic RubyHash<K,V> merge(java.util.Map<? extends K,? extends V> otherHash)
RubyHash
.otherHash
- any MapRubyHash
public RubyHash<K,V> merge(java.util.Map<K,V> otherHash, EntryMergeBlock<? super K,V> block)
RubyHash
. Resolves the
final value of the key which is conflicted by given block.otherHash
- any Mapblock
- to determine which value is used when key is conflictRubyHash
public RubyHash<K,V> mergeǃ(java.util.Map<? extends K,? extends V> otherHash)
otherHash
- any MapRubyHash
public RubyHash<K,V> mergeǃ(java.util.Map<? extends K,? extends V> otherHash, EntryMergeBlock<? super K,V> block)
otherHash
- any Mapblock
- to determine which value is used when key is conflictRubyHash
public RubyHash<K,V> put(java.util.Map.Entry<? extends K,? extends V> entry)
RubyHash
directly.entry
- an EntryRubyHash
public RubyHash<K,V> put(java.util.Map.Entry<? extends K,? extends V>... entries)
RubyHash
directly.entries
- an array of entriesRubyHash
public java.util.Map.Entry<K,V> rassoc(V value)
value
- to be foundpublic RubyEnumerator<java.util.Map.Entry<K,V>> rejectǃ()
RubyEnumerator
of entries of this RubyHash
.RubyEnumerator
public RubyHash<K,V> rejectǃ(EntryBooleanBlock<? super K,? super V> block)
block
- to filter elementsRubyHash
or nullpublic RubyHash<K,V> replace(java.util.Map<? extends K,? extends V> otherHash)
otherHash
- any MapRubyHash
public V store(K key, V value)
key
- of Entryvalue
- of Entrypublic java.lang.String toS()
toString()
.public RubyHash<K,V> update(java.util.Map<? extends K,? extends V> otherHash)
mergeǃ(Map)
.otherHash
- any Mappublic RubyHash<K,V> update(java.util.Map<? extends K,? extends V> otherHash, EntryMergeBlock<? super K,V> block)
mergeǃ(Map, EntryMergeBlock)
.otherHash
- any Mapblock
- to determine which value is used when key is conflictpublic boolean allʔ(EntryBooleanBlock<? super K,? super V> block)
RubyEnumerable.allʔ(BooleanBlock)
public boolean anyʔ(EntryBooleanBlock<? super K,? super V> block)
RubyEnumerable.anyʔ(BooleanBlock)
public <S> RubyEnumerator<java.util.Map.Entry<S,RubyArray<java.util.Map.Entry<K,V>>>> chunk(EntryTransformBlock<? super K,? super V,? extends S> block)
RubyEnumerable.chunk(TransformBlock)
public <S> RubyArray<S> collect(EntryTransformBlock<? super K,? super V,? extends S> block)
public <S> RubyArray<S> collectConcat(EntryTransformBlock<? super K,? super V,? extends java.util.List<S>> block)
public int count(EntryBooleanBlock<? super K,? super V> block)
RubyEnumerable.count(BooleanBlock)
public void cycle(EntryBlock<? super K,? super V> block)
RubyEnumerable.cycle(Block)
public void cycle(int n, EntryBlock<? super K,? super V> block)
RubyEnumerable.cycle(int, Block)
public java.util.Map.Entry<K,V> detect(EntryBooleanBlock<? super K,? super V> block)
RubyEnumerable.detect(BooleanBlock)
public RubyArray<java.util.Map.Entry<K,V>> dropWhile(EntryBooleanBlock<? super K,? super V> block)
public RubyEnumerable<java.util.Map.Entry<K,V>> eachEntry(EntryBlock<? super K,? super V> block)
RubyEnumerable.eachEntry(Block)
public java.util.Map.Entry<K,V> find(EntryBooleanBlock<? super K,? super V> block)
RubyEnumerable.find(BooleanBlock)
public RubyArray<java.util.Map.Entry<K,V>> findAll(EntryBooleanBlock<? super K,? super V> block)
RubyEnumerable.findAll(BooleanBlock)
public java.lang.Integer findIndex(EntryBooleanBlock<? super K,? super V> block)
public <S> RubyArray<S> flatMap(EntryTransformBlock<? super K,? super V,? extends java.util.List<S>> block)
public <S> RubyArray<S> grep(java.lang.String regex, EntryTransformBlock<? super K,? super V,? extends S> block)
public <S> RubyHash<S,RubyArray<java.util.Map.Entry<K,V>>> groupBy(EntryTransformBlock<? super K,? super V,? extends S> block)
public <S> RubyArray<S> map(EntryTransformBlock<? super K,? super V,? extends S> block)
RubyEnumerable.map(TransformBlock)
public <S> java.util.Map.Entry<K,V> maxBy(java.util.Comparator<? super S> comp, EntryTransformBlock<? super K,? super V,? extends S> block)
public <S> java.util.Map.Entry<K,V> maxBy(EntryTransformBlock<? super K,? super V,? extends S> block)
RubyEnumerable.maxBy(TransformBlock)
public <S> java.util.Map.Entry<K,V> minBy(java.util.Comparator<? super S> comp, EntryTransformBlock<? super K,? super V,? extends S> block)
public <S> java.util.Map.Entry<K,V> minBy(EntryTransformBlock<? super K,? super V,? extends S> block)
RubyEnumerable.minBy(TransformBlock)
public <S> RubyArray<java.util.Map.Entry<K,V>> minmaxBy(java.util.Comparator<? super S> comp, EntryTransformBlock<? super K,? super V,? extends S> block)
public <S> RubyArray<java.util.Map.Entry<K,V>> minmaxBy(EntryTransformBlock<? super K,? super V,? extends S> block)
public boolean noneʔ(EntryBooleanBlock<? super K,? super V> block)
RubyEnumerable.noneʔ(BooleanBlock)
public boolean oneʔ(EntryBooleanBlock<? super K,? super V> block)
RubyEnumerable.oneʔ(BooleanBlock)
public RubyArray<RubyArray<java.util.Map.Entry<K,V>>> partition(EntryBooleanBlock<? super K,? super V> block)
public RubyArray<java.util.Map.Entry<K,V>> reject(EntryBooleanBlock<? super K,? super V> block)
RubyEnumerable.reject(BooleanBlock)
public RubyEnumerable<java.util.Map.Entry<K,V>> reverseEach(EntryBlock<? super K,? super V> block)
RubyEnumerable.reverseEach(Block)
public RubyArray<java.util.Map.Entry<K,V>> select(EntryBooleanBlock<? super K,? super V> block)
RubyEnumerable.select(BooleanBlock)
public RubyEnumerator<RubyArray<java.util.Map.Entry<K,V>>> sliceBefore(EntryBooleanBlock<? super K,? super V> block)
public <S> RubyArray<java.util.Map.Entry<K,V>> sortBy(java.util.Comparator<? super S> comp, EntryTransformBlock<? super K,? super V,? extends S> block)
public <S> RubyArray<java.util.Map.Entry<K,V>> sortBy(EntryTransformBlock<? super K,? super V,? extends S> block)
public RubyArray<java.util.Map.Entry<K,V>> takeWhile(EntryBooleanBlock<? super K,? super V> block)
public RubyArray<V> valuesAt(java.lang.Object... keys)
keys
- to retrieve valuesRubyArray
public RubyArray<V> valuesAt(java.lang.Iterable<?> keys)
keys
- to retrieve valuesRubyArray
public boolean valueʔ(java.lang.Object value)
value
- to be checkedpublic boolean containsKey(java.lang.Object key)
public boolean containsValue(java.lang.Object value)
public boolean equals(java.lang.Object o)
public int hashCode()
public java.lang.String toString()
toString
in class RubyEnumerable<java.util.Map.Entry<K,V>>