Class BmLongHashSet
- java.lang.Object
-
- com._1c.g5.v8.bm.common.collections.BmLongHashSet
-
- All Implemented Interfaces:
IBmLongSet
public class BmLongHashSet extends Object implements IBmLongSet
This code is adoption of 'HashMap' from Apache Harmony refactored to support primitive long keys.
This implementation doesn't support removal of elements via itearator.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
BmLongHashSet.MapIterator
-
Nested classes/interfaces inherited from interface com._1c.g5.v8.bm.common.collections.IBmLongSet
IBmLongSet.Entry
-
-
Constructor Summary
Constructors Constructor Description BmLongHashSet()
Constructs a new emptyHashMap
instance.BmLongHashSet(int capacity)
Constructs a newHashMap
instance with the specified capacity.BmLongHashSet(int capacity, float loadFactor)
Constructs a newHashMap
instance with the specified capacity and load factor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(long key)
Adds the specified element.void
addAll(long[] array)
Adds all the values from the specified array.void
addAll(IBmLongSet values)
Adds all the values from the specified collection.void
addAll(Iterable<Long> values)
Adds all the values from the specified collection.void
clear()
Removes all the elements.protected int
computeKeyHash(long key)
Computes key hash.boolean
contains(long key)
Checks if the set contains the specified element.boolean
containsAny(BmLongHashSet value)
Checks if this set contains any element from the specified one.Iterable<IBmLongSet.Entry>
entryIterator()
Gets entry iterator.boolean
isEmpty()
Checks whether this set is empty.IBmLongIterator
iterator()
Gets the long value iteratorCollection<Long>
keys()
Gets collection of elements.boolean
remove(long key)
Removes the specified element.void
removeAll(IBmLongSet set)
Removes from this set all of its elements that are contained in the specified set.int
size()
Returns the number of elements in this set.
-
-
-
Constructor Detail
-
BmLongHashSet
public BmLongHashSet()
Constructs a new emptyHashMap
instance.
-
BmLongHashSet
public BmLongHashSet(int capacity)
Constructs a newHashMap
instance with the specified capacity.- Parameters:
capacity
- the initial capacity of this hash map.- Throws:
IllegalArgumentException
- when the capacity is less than zero.
-
BmLongHashSet
public BmLongHashSet(int capacity, float loadFactor)
Constructs a newHashMap
instance with the specified capacity and load factor.- Parameters:
capacity
- the initial capacity of this hash map.loadFactor
- the initial load factor.- Throws:
IllegalArgumentException
- when the capacity is less than zero or the load factor is less or equal to zero.
-
-
Method Detail
-
add
public void add(long key)
Description copied from interface:IBmLongSet
Adds the specified element.- Specified by:
add
in interfaceIBmLongSet
- Parameters:
key
- the element to add.
-
addAll
public void addAll(IBmLongSet values)
Description copied from interface:IBmLongSet
Adds all the values from the specified collection.- Specified by:
addAll
in interfaceIBmLongSet
- Parameters:
values
- the collection of values to add.
-
addAll
public void addAll(Iterable<Long> values)
Description copied from interface:IBmLongSet
Adds all the values from the specified collection.- Specified by:
addAll
in interfaceIBmLongSet
- Parameters:
values
- the collection of values to add.
-
addAll
public void addAll(long[] array)
Description copied from interface:IBmLongSet
Adds all the values from the specified array.- Specified by:
addAll
in interfaceIBmLongSet
- Parameters:
array
- the array. May not benull
.
-
clear
public void clear()
Description copied from interface:IBmLongSet
Removes all the elements.- Specified by:
clear
in interfaceIBmLongSet
- See Also:
IBmLongSet.isEmpty()
,IBmLongSet.size()
-
contains
public boolean contains(long key)
Description copied from interface:IBmLongSet
Checks if the set contains the specified element.- Specified by:
contains
in interfaceIBmLongSet
- Parameters:
key
- the element.- Returns:
true
if set contains the specified element,false
otherwise.
-
containsAny
public boolean containsAny(BmLongHashSet value)
Checks if this set contains any element from the specified one.- Parameters:
set
- the set to run the check against, may not benull
.- Returns:
true
if this map contains any element from the specified one,false
otherwise.
-
entryIterator
public Iterable<IBmLongSet.Entry> entryIterator()
Description copied from interface:IBmLongSet
Gets entry iterator.- Specified by:
entryIterator
in interfaceIBmLongSet
- Returns:
- an entry iterator.
-
iterator
public IBmLongIterator iterator()
Description copied from interface:IBmLongSet
Gets the long value iterator- Specified by:
iterator
in interfaceIBmLongSet
- Returns:
- The iterator of values. May not be
null
-
isEmpty
public boolean isEmpty()
Description copied from interface:IBmLongSet
Checks whether this set is empty.- Specified by:
isEmpty
in interfaceIBmLongSet
- Returns:
true
if this set has no elements,false
otherwise.- See Also:
IBmLongSet.size()
-
keys
public Collection<Long> keys()
Description copied from interface:IBmLongSet
Gets collection of elements.- Specified by:
keys
in interfaceIBmLongSet
- Returns:
- the collection of elements.
-
remove
public boolean remove(long key)
Description copied from interface:IBmLongSet
Removes the specified element.- Specified by:
remove
in interfaceIBmLongSet
- Parameters:
key
- the element to remove.- Returns:
true
if this set contained the specified element,false
otherwise.
-
removeAll
public void removeAll(IBmLongSet set)
Removes from this set all of its elements that are contained in the specified set.- Parameters:
set
- The set containing elements to be removed from this set, may not benull
.
-
size
public int size()
Description copied from interface:IBmLongSet
Returns the number of elements in this set.- Specified by:
size
in interfaceIBmLongSet
- Returns:
- the number of elements in this set.
-
computeKeyHash
protected int computeKeyHash(long key)
Computes key hash.- Parameters:
key
- The key to compute hash for.- Returns:
- the key hash.
-
-