本文整理了Java中java.util.LinkedHashMap.size()
方法的一些代码示例,展示了LinkedHashMap.size()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。LinkedHashMap.size()
方法的具体详情如下:
包路径:java.util.LinkedHashMap
类名称:LinkedHashMap
方法名:size
暂无
代码示例来源:origin: requery/requery
@Override
protected boolean removeEldestEntry(Map.Entry eldest) {
synchronized (elements) {
if (elements.size() > count) {
PreparedStatement statement = (PreparedStatement) eldest.getValue();
closeStatement(statement);
return true;
}
}
return false;
}
};
代码示例来源:origin: square/okhttp
/**
* Deletes all stored values from the cache. In-flight edits will complete normally but their
* values will not be stored.
*/
public synchronized void evictAll() throws IOException {
initialize();
// Copying for safe iteration.
for (Entry entry : lruEntries.values().toArray(new Entry[lruEntries.size()])) {
removeEntry(entry);
}
mostRecentTrimFailed = false;
}
代码示例来源:origin: btraceio/btrace
public String get(int idx) {
if (idx >= 0 && idx < map.size()) {
Iterator<Map.Entry<String, String>> argsIterator = map.entrySet().iterator();
for (int i = 0; i < idx; i++) {
argsIterator.next();
}
Map.Entry<String, String> e = argsIterator.next();
return e.getValue() != null ? e.getKey() + "=" + e.getValue() : e.getKey();
} else {
return null;
}
}
代码示例来源:origin: oracle/opengrok
/** find repeating terms and assign them ordinal values */
private LinkedHashMap<Term,Integer> repeatingTerms() {
LinkedHashMap<Term,Integer> tord = new LinkedHashMap<>();
HashMap<Term,Integer> tcnt = new HashMap<>();
for (PhrasePositions pp : phrasePositions) {
for (Term t : pp.terms) {
Integer cnt0 = tcnt.get(t);
Integer cnt = cnt0==null ? Integer.valueOf(1) : Integer.valueOf(1+cnt0.intValue());
tcnt.put(t, cnt);
if (cnt==2) {
tord.put(t,tord.size());
}
}
}
return tord;
}
代码示例来源:origin: jfinal/jfinal
public Object eval(Scope scope) {
LinkedHashMap<Object, Object> valueMap = new LinkedHashMap<Object, Object>(map.size());
for (Entry<Object, Expr> e : map.entrySet()) {
valueMap.put(e.getKey(), e.getValue().eval(scope));
}
return valueMap;
}
}
代码示例来源:origin: neo4j/neo4j
private static Collection<Path> hitsToPaths( Collection<Hit> depthHits, Node start, Node end, boolean stopAsap, int maxResultCount )
{
LinkedHashMap<String,Path> paths = new LinkedHashMap<>();
for ( Hit hit : depthHits )
{
for ( Path path : hitToPaths( hit, start, end, stopAsap ) )
{
paths.put( path.toString(), path );
if ( paths.size() >= maxResultCount )
{
break;
}
}
}
return paths.values();
}
代码示例来源:origin: magro/memcached-session-manager
address2Ids.put(getSingleShortNodeDefinition(singleNodeMatcher), null);
final String hostname = matcher.group( 1 );
final int port = Integer.parseInt( matcher.group( 2 ) );
address2Ids.put(new InetSocketAddress( hostname, port ), null);
while (matcher.find()) {
final Pair<String, InetSocketAddress> nodeInfo = getRegularNodeDefinition(matcher);
address2Ids.put(nodeInfo.getSecond(), nodeInfo.getFirst());
final List<String> failoverNodeIds = initFailoverNodes(failoverNodes, address2Ids.values());
if(address2Ids.size() == 1 && failoverNodeIds.size() >= 1) {
throw new IllegalArgumentException("For a single memcached node there should/must no failoverNodes be specified.");
for(final Map.Entry<InetSocketAddress, String> address2Id : address2Ids.entrySet()) {
final String nodeId = address2Id.getValue();
if (nodeId != null && !failoverNodeIds.contains(nodeId) ) {
primaryNodeIds.add(nodeId);
代码示例来源:origin: wildfly/wildfly
Many(final Credential c1, final Many subsequent) {
LinkedHashMap<Key, Credential> map = new LinkedHashMap<>(subsequent.map.size() + 1);
map.put(Key.of(c1), c1);
map.putAll(subsequent.map);
this.map = map;
int hc = 0;
for (Credential credential : map.values()) {
hc ^= typeHash(credential);
}
hashCode = hc;
assert size() > 2;
}
代码示例来源:origin: apache/flink
if (this.numFields == config.getFieldToSerializerConfigSnapshot().size()) {
: config.getFieldToSerializerConfigSnapshot().entrySet()) {
int fieldIndex = findField(fieldToConfigSnapshotEntry.getKey());
if (fieldIndex != -1) {
reorderedFields[i] = fields[fieldIndex];
fieldToConfigSnapshotEntry.getValue().f0,
UnloadableDummyTypeSerializer.class,
fieldToConfigSnapshotEntry.getValue().f1,
fieldSerializers[fieldIndex]);
for (Tuple2<TypeSerializer<?>, TypeSerializerSnapshot<?>> previousRegisteredSerializerConfig : previousRegistrations.values()) {
: config.getNonRegisteredSubclassesToSerializerConfigSnapshots().entrySet()) {
TypeSerializer<?> cachedSerializer = createSubclassSerializer(previousCachedEntry.getKey());
previousCachedEntry.getValue().f0,
UnloadableDummyTypeSerializer.class,
previousCachedEntry.getValue().f1,
rebuiltCache.put(previousCachedEntry.getKey(), cachedSerializer);
} else {
return CompatibilityResult.requiresMigration();
代码示例来源:origin: org.codehaus.jackson/jackson-mapper-asl
return;
int size = _properties.size();
Map<String, POJOPropertyBuilder> all;
for (POJOPropertyBuilder prop : _properties.values()) {
all.put(prop.getName(), prop);
POJOPropertyBuilder w = all.get(name);
if (w == null) { // also, as per [JACKSON-268], we will allow use of "implicit" names
for (POJOPropertyBuilder prop : _properties.values()) {
if (name.equals(prop.getInternalName())) {
w = prop;
代码示例来源:origin: markzhai/AndroidPerformanceMonitor
@Override
protected void doSample() {
StringBuilder stringBuilder = new StringBuilder();
for (StackTraceElement stackTraceElement : mCurrentThread.getStackTrace()) {
stringBuilder
.append(stackTraceElement.toString())
.append(BlockInfo.SEPARATOR);
}
synchronized (sStackMap) {
if (sStackMap.size() == mMaxEntryCount && mMaxEntryCount > 0) {
sStackMap.remove(sStackMap.keySet().iterator().next());
}
sStackMap.put(System.currentTimeMillis(), stringBuilder.toString());
}
}
}
代码示例来源:origin: apache/flink
/**
* Copy-constructor that does not copy transient fields. They will be initialized once required.
*/
protected KryoSerializer(KryoSerializer<T> toCopy) {
this.type = checkNotNull(toCopy.type, "Type class cannot be null.");
this.defaultSerializerClasses = toCopy.defaultSerializerClasses;
this.defaultSerializers = new LinkedHashMap<>(toCopy.defaultSerializers.size());
this.kryoRegistrations = new LinkedHashMap<>(toCopy.kryoRegistrations.size());
// deep copy the serializer instances in defaultSerializers
for (Map.Entry<Class<?>, ExecutionConfig.SerializableSerializer<?>> entry :
toCopy.defaultSerializers.entrySet()) {
this.defaultSerializers.put(entry.getKey(), deepCopySerializer(entry.getValue()));
}
// deep copy the serializer instances in kryoRegistrations
for (Map.Entry<String, KryoRegistration> entry : toCopy.kryoRegistrations.entrySet()) {
KryoRegistration kryoRegistration = entry.getValue();
if (kryoRegistration.getSerializerDefinitionType() == KryoRegistration.SerializerDefinitionType.INSTANCE) {
ExecutionConfig.SerializableSerializer<? extends Serializer<?>> serializerInstance =
kryoRegistration.getSerializableSerializerInstance();
if (serializerInstance != null) {
kryoRegistration = new KryoRegistration(
kryoRegistration.getRegisteredClass(),
deepCopySerializer(serializerInstance));
}
}
this.kryoRegistrations.put(entry.getKey(), kryoRegistration);
}
}
代码示例来源:origin: gchq/Gaffer
@Override
public Map<String, Object> _apply(final Element element) {
final Map<String, Object> map = new LinkedHashMap<>(fields.size() + constants.size());
for (final Map.Entry<String, String> entry : fields.entrySet()) {
final Object value = getFieldValue(element, entry.getKey());
if (null != value) {
map.put(entry.getValue(), value);
}
}
map.putAll(constants);
return map;
}
代码示例来源:origin: org.codehaus.jackson/jackson-mapper-asl
protected void _renameUsing(PropertyNamingStrategy naming)
POJOPropertyBuilder[] props = _properties.values().toArray(new POJOPropertyBuilder[_properties.size()]);
_properties.clear();
for (POJOPropertyBuilder prop : props) {
_properties.put(name, prop);
} else {
old.addAll(prop);
代码示例来源:origin: prestodb/presto
/**
* Deletes all stored values from the cache. In-flight edits will complete normally but their
* values will not be stored.
*/
public synchronized void evictAll() throws IOException {
initialize();
// Copying for safe iteration.
for (Entry entry : lruEntries.values().toArray(new Entry[lruEntries.size()])) {
removeEntry(entry);
}
mostRecentTrimFailed = false;
}
代码示例来源:origin: apache/phoenix
columns.put(column, column);
int positionOffset = columns.size();
if (saltBucketNum != null) {
positionOffset++;
if (columns.put(column, column) != null) {
throw new ColumnAlreadyExistsException(schemaName, tableName, column.getName().getString());
.setIndexes(Collections.emptyList())
.setPhysicalNames(ImmutableList.of())
.setColumns(columns.values())
.build();
connection.addTable(table, MetaDataProtocol.MIN_TABLE_TIMESTAMP);
linkStatement.setString(2, schemaNameToUse);
linkStatement.setString(3, tableNameToUse);
linkStatement.setString(4, entry.getKey());
linkStatement.setInt(5, entry.getValue());
linkStatement.execute();
List<Mutation> columnMetadata = Lists.newArrayListWithExpectedSize(columns.size());
boolean isRegularView = (tableType == PTableType.VIEW && viewType!=ViewType.MAPPED);
try (PreparedStatement colUpsert = connection.prepareStatement(INSERT_COLUMN_CREATE_TABLE)) {
for (Map.Entry<PColumn, PColumn> entry : columns.entrySet()) {
PColumn column = entry.getValue();
final int columnPosition = column.getPosition();
代码示例来源:origin: wildfly/wildfly
Many(final Credential c1, final Credential c2, final Many subsequent) {
LinkedHashMap<Key, Credential> map = new LinkedHashMap<>(subsequent.map.size() + 2);
map.put(Key.of(c1), c1);
map.put(Key.of(c2), c2);
map.putAll(subsequent.map);
this.map = map;
int hc = 0;
for (Credential credential : map.values()) {
hc ^= typeHash(credential);
}
hashCode = hc;
assert size() > 2;
}
代码示例来源:origin: prometheus/jmx_exporter
StringBuilder name = new StringBuilder();
name.append(domain);
if (beanProperties.size() > 0) {
name.append(SEP);
name.append(beanProperties.values().iterator().next());
if (beanProperties.size() > 1) {
Iterator<Map.Entry<String, String>> iter = beanProperties.entrySet().iterator();
String labelName = safeName(entry.getKey());
if (config.lowercaseOutputLabelNames) {
labelName = labelName.toLowerCase();
labelValues.add(entry.getValue());
代码示例来源:origin: camunda/camunda-bpm-platform
return;
int size = _properties.size();
Map<String, POJOPropertyBuilder> all;
for (POJOPropertyBuilder prop : _properties.values()) {
all.put(prop.getName(), prop);
POJOPropertyBuilder w = all.get(name);
if (w == null) { // also, as per [JACKSON-268], we will allow use of "implicit" names
for (POJOPropertyBuilder prop : _properties.values()) {
if (name.equals(prop.getInternalName())) {
w = prop;
代码示例来源:origin: robovm/robovm
private void trimToSize(int maxSize) {
while (map.size() > maxSize) {
Map.Entry<K, V> toEvict = map.eldest();
K key = toEvict.getKey();
V value = toEvict.getValue();
map.remove(key);
entryEvicted(key, value);
}
}
内容来源于网络,如有侵权,请联系作者删除!