本文整理汇总了Java中com.carrotsearch.hppc.ObjectIntHashMap.put方法的典型用法代码示例。如果您正苦于以下问题:Java ObjectIntHashMap.put方法的具体用法?Java ObjectIntHashMap.put怎么用?Java ObjectIntHashMap.put使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.carrotsearch.hppc.ObjectIntHashMap
的用法示例。
在下文中一共展示了ObjectIntHashMap.put方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: readObject
import com.carrotsearch.hppc.ObjectIntHashMap; //导入方法依赖的package包/类
private void readObject (ObjectInputStream in) throws IOException, ClassNotFoundException {
lock = new ReentrantReadWriteLock();
lock.writeLock().lock();
try {
int version = in.readInt();
int size = in.readInt();
entries = new ArrayList(size);
map = new ObjectIntHashMap(size);
for (int i = 0; i < size; i++) {
Object o = in.readObject();
map.put(o, i);
entries.add(o);
}
growthStopped = in.readBoolean();
entryClass = (Class) in.readObject();
if (version > 0) { // instanced id added in version 1S
instanceId = (VMID) in.readObject();
}
} finally {
lock.writeLock().unlock();
}
}
示例2: createString
import com.carrotsearch.hppc.ObjectIntHashMap; //导入方法依赖的package包/类
private String createString(String[] tokens, Map<String, List<BytesRef>> payloads, int encoding, char delimiter) {
String resultString = "";
ObjectIntHashMap<String> payloadCounter = new ObjectIntHashMap<>();
for (String token : tokens) {
if (!payloadCounter.containsKey(token)) {
payloadCounter.putIfAbsent(token, 0);
} else {
payloadCounter.put(token, payloadCounter.get(token) + 1);
}
resultString = resultString + token;
BytesRef payload = payloads.get(token).get(payloadCounter.get(token));
if (payload.length > 0) {
resultString = resultString + delimiter;
switch (encoding) {
case 0: {
resultString = resultString + Float.toString(PayloadHelper.decodeFloat(payload.bytes, payload.offset));
break;
}
case 1: {
resultString = resultString + Integer.toString(PayloadHelper.decodeInt(payload.bytes, payload.offset));
break;
}
case 2: {
resultString = resultString + payload.utf8ToString();
break;
}
default: {
throw new ElasticsearchException("unsupported encoding type");
}
}
}
resultString = resultString + " ";
}
return resultString;
}
示例3: test
import com.carrotsearch.hppc.ObjectIntHashMap; //导入方法依赖的package包/类
@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();
}
示例4: objectCollectionAsIterableTest
import com.carrotsearch.hppc.ObjectIntHashMap; //导入方法依赖的package包/类
@Test
public void objectCollectionAsIterableTest() {
ObjectIntHashMap<String> foo = new ObjectIntHashMap<>();
foo.put("foo", 1);
foo.put("foo2", 2);
foo.put("bar", 8);
final ImmutableSet<String> reference = ImmutableSet.of("foo", "foo2", "bar");
assertEquals(reference, ImmutableSet.copyOf(HppcUtils.asJavaIterable(foo.keys())));
}