本文整理了Java中com.carrotsearch.hppc.ObjectIntHashMap.size()
方法的一些代码示例,展示了ObjectIntHashMap.size()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ObjectIntHashMap.size()
方法的具体详情如下:
包路径:com.carrotsearch.hppc.ObjectIntHashMap
类名称:ObjectIntHashMap
方法名:size
暂无
代码示例来源:origin: carrotsearch/hppc
/**
* {@inheritDoc}
*/
public boolean isEmpty() {
return size() == 0;
}
代码示例来源:origin: carrotsearch/hppc
/**
* {@inheritDoc}
*/
@Override
public int putAll(ObjectIntAssociativeContainer<? extends KType> container) {
final int count = size();
for (ObjectIntCursor<? extends KType> c : container) {
put(c.key, c.value);
}
return size() - count;
}
代码示例来源:origin: carrotsearch/hppc
/**
* Puts all key/value pairs from a given iterable into this map.
*/
@Override
public int putAll(Iterable<? extends ObjectIntCursor<? extends KType>> iterable){
final int count = size();
for (ObjectIntCursor<? extends KType> c : iterable) {
put(c.key, c.value);
}
return size() - count;
}
代码示例来源:origin: carrotsearch/hppc
/**
* Return true if all keys of some other container exist in this container.
* Equality comparison is performed with this object's {@link #equals(Object, Object)}
* method.
*/
protected boolean equalElements(ObjectIntHashMap<?> other) {
if (other.size() != size()) {
return false;
}
for (ObjectIntCursor<?> c : other) {
KType key = (KType) c.key;
if (!containsKey(key) ||
!((get(key)) == (c.value))) {
return false;
}
}
return true;
}
代码示例来源:origin: carrotsearch/hppc
/**
* {@inheritDoc}
*/
@Override
public int removeAll(ObjectPredicate<? super KType> predicate) {
final int before = size();
if (hasEmptyKey) {
if (predicate.apply(null)) {
hasEmptyKey = false;
values[mask + 1] = 0;
}
}
final KType[] keys = (KType[]) this.keys;
for (int slot = 0, max = this.mask; slot <= max;) {
KType existing;
if (!((existing = keys[slot]) == null) &&
predicate.apply(existing)) {
// Shift, do not increment slot.
shiftConflictingKeys(slot);
} else {
slot++;
}
}
return before - size();
}
代码示例来源:origin: carrotsearch/hppc
/**
* {@inheritDoc}
*/
@Override
public int removeAll(ObjectIntPredicate<? super KType> predicate) {
final int before = size();
final int mask = this.mask;
if (hasEmptyKey) {
if (predicate.apply(null, values[mask + 1])) {
hasEmptyKey = false;
values[mask + 1] = 0;
}
}
final KType[] keys = (KType[]) this.keys;
final int[] values = this.values;
for (int slot = 0; slot <= mask;) {
KType existing;
if (!((existing = keys[slot]) == null) &&
predicate.apply(existing, values[slot])) {
// Shift, do not increment slot.
shiftConflictingKeys(slot);
} else {
slot++;
}
}
return before - size();
}
代码示例来源:origin: carrotsearch/hppc
final int before = size();
if (other.size() >= size() &&
other instanceof ObjectLookupContainer<?>) {
if (hasEmptyKey) {
return before - size();
代码示例来源:origin: carrotsearch/hppc
/**
* This method is invoked when there is a new key/ value pair to be inserted into
* the buffers but there is not enough empty slots to do so.
*
* New buffers are allocated. If this succeeds, we know we can proceed
* with rehashing so we assign the pending element to the previous buffer
* (possibly violating the invariant of having at least one empty slot)
* and rehash all keys, substituting new buffers at the end.
*/
protected void allocateThenInsertThenRehash(int slot, KType pendingKey, int pendingValue) {
assert assigned == resizeAt
&& (((KType) keys[slot]) == null)
&& !((pendingKey) == null);
// Try to allocate new buffers first. If we OOM, we leave in a consistent state.
final KType[] prevKeys = (KType[]) this.keys;
final int[] prevValues = this.values;
allocateBuffers(nextBufferSize(mask + 1, size(), loadFactor));
assert this.keys.length > prevKeys.length;
// We have succeeded at allocating new data so insert the pending key/value at
// the free slot in the old arrays before rehashing.
prevKeys[slot] = pendingKey;
prevValues[slot] = pendingValue;
// Rehash old keys, including the pending key.
rehash(prevKeys, prevValues);
}
代码示例来源:origin: harbby/presto-connectors
/**
* {@inheritDoc}
*/
public boolean isEmpty() {
return size() == 0;
}
代码示例来源:origin: clir/clearnlp
public int size()
{
return g_map.size();
}
代码示例来源:origin: harbby/presto-connectors
/**
* {@inheritDoc}
*/
@Override
public int putAll(ObjectIntAssociativeContainer<? extends KType> container) {
final int count = size();
for (ObjectIntCursor<? extends KType> c : container) {
put(c.key, c.value);
}
return size() - count;
}
代码示例来源:origin: harbby/presto-connectors
/**
* Puts all key/value pairs from a given iterable into this map.
*/
@Override
public int putAll(Iterable<? extends ObjectIntCursor<? extends KType>> iterable){
final int count = size();
for (ObjectIntCursor<? extends KType> c : iterable) {
put(c.key, c.value);
}
return size() - count;
}
代码示例来源:origin: org.elasticsearch/elasticsearch
int numberOfAttributes = nodesPerAttribute.size();
List<String> fullValues = forcedAwarenessAttributes.get(awarenessAttribute);
if (fullValues != null) {
代码示例来源:origin: harbby/presto-connectors
/**
* Return true if all keys of some other container exist in this container.
* Equality comparison is performed with this object's {@link #equals(Object, Object)}
* method.
*/
protected boolean equalElements(ObjectIntHashMap<?> other) {
if (other.size() != size()) {
return false;
}
for (ObjectIntCursor<?> c : other) {
KType key = (KType) c.key;
if (!containsKey(key) ||
!((get(key)) == (c.value))) {
return false;
}
}
return true;
}
代码示例来源:origin: harbby/presto-connectors
/**
* {@inheritDoc}
*/
@Override
public int removeAll(ObjectPredicate<? super KType> predicate) {
final int before = size();
if (hasEmptyKey) {
if (predicate.apply(null)) {
hasEmptyKey = false;
values[mask + 1] = 0;
}
}
final KType[] keys = (KType[]) this.keys;
for (int slot = 0, max = this.mask; slot <= max;) {
KType existing;
if (!((existing = keys[slot]) == null) &&
predicate.apply(existing)) {
// Shift, do not increment slot.
shiftConflictingKeys(slot);
} else {
slot++;
}
}
return before - size();
}
代码示例来源:origin: mikvor/hashmapTest
@Override
public int test() {
final ObjectIntHashMap<Integer> m_map = new ObjectIntHashMap<>( m_keys.length, m_fillFactor );
for ( int i = 0; i < m_keys.length; ++i )
m_map.put( m_keys[ i ], i );
for ( int i = 0; i < m_keys2.length; ++i )
m_map.put( m_keys2[ i ], i );
return m_map.size();
}
}
代码示例来源:origin: harbby/presto-connectors
/**
* This method is invoked when there is a new key/ value pair to be inserted into
* the buffers but there is not enough empty slots to do so.
*
* New buffers are allocated. If this succeeds, we know we can proceed
* with rehashing so we assign the pending element to the previous buffer
* (possibly violating the invariant of having at least one empty slot)
* and rehash all keys, substituting new buffers at the end.
*/
protected void allocateThenInsertThenRehash(int slot, KType pendingKey, int pendingValue) {
assert assigned == resizeAt
&& (((KType) keys[slot]) == null)
&& !((pendingKey) == null);
// Try to allocate new buffers first. If we OOM, we leave in a consistent state.
final KType[] prevKeys = (KType[]) this.keys;
final int[] prevValues = this.values;
allocateBuffers(nextBufferSize(mask + 1, size(), loadFactor));
assert this.keys.length > prevKeys.length;
// We have succeeded at allocating new data so insert the pending key/value at
// the free slot in the old arrays before rehashing.
prevKeys[slot] = pendingKey;
prevValues[slot] = pendingValue;
// Rehash old keys, including the pending key.
rehash(prevKeys, prevValues);
}
代码示例来源:origin: mikvor/hashmapTest
@Override
public int test() {
final ObjectIntHashMap<Integer> m_map = new ObjectIntHashMap<>( m_keys.length / 2 + 1, m_fillFactor );
int add = 0, remove = 0;
while ( add < m_keys.length )
{
m_map.put( m_keys[ add ], add );
++add;
m_map.put( m_keys[ add ], add );
++add;
m_map.remove( m_keys[ remove++ ] );
}
return m_map.size();
}
}
代码示例来源:origin: harbby/presto-connectors
@Override
public void writeTo(StreamOutput out) throws IOException {
out.writeVInt(versions.size());
for (ObjectIntCursor<JvmVersion> v : versions) {
v.key.writeTo(out);
out.writeVInt(v.value);
}
out.writeVLong(threads);
out.writeVLong(maxUptime);
out.writeVLong(heapUsed);
out.writeVLong(heapMax);
}
代码示例来源:origin: harbby/presto-connectors
@Override
public void writeTo(StreamOutput out) throws IOException {
out.writeVInt(availableProcessors);
if (out.getVersion().onOrAfter(Version.V_2_1_0)) {
out.writeVInt(allocatedProcessors);
}
out.writeLong(availableMemory);
out.writeVInt(names.size());
for (ObjectIntCursor<String> name : names) {
out.writeString(name.key);
out.writeVInt(name.value);
}
}
内容来源于网络,如有侵权,请联系作者删除!