Java源码示例:org.eclipse.collections.impl.map.mutable.primitive.ObjectIntHashMap

示例1
private Timestamp findCommonValue(List data)
{
    ObjectIntHashMap<Timestamp> counts = new ObjectIntHashMap(data.size());
    TimestampAttribute attr = (TimestampAttribute) this;

    for(int i=0;i<data.size();i++)
    {
        Timestamp t = attr.timestampValueOf(data.get(i));
        if (t != null)
        {
            counts.addToValue(t, 1);
        }
    }

    MaxProc procedure = new MaxProc();
    counts.forEachKeyValue(procedure);
    if (procedure.maxCount > data.size() >> 4)
    {
        return procedure.max;
    }
    return null;
}
 
示例2
public CachedPostingListCounter rebuildCache() {
    MinMaxPriorityQueue<Entry> mostExpensive = MinMaxPriorityQueue
            .maximumSize(32).expectedSize(32).create();
    synchronized (this) {
        for (ObjectLongPair<int[]> p : frequency.keyValuesView()) {
            mostExpensive.add(new Entry(p.getOne(), p.getTwo()));
        }
    }
    ObjectIntHashMap<int[]> postingListMapping = new ObjectIntHashMap<>();
    int[] bitVector = new int[nDocuments];
    int length = mostExpensive.size();
    for (int i = 0; i < length; i++) {
        Entry e = mostExpensive.removeFirst();
        int[] docIds = e.docIds;
        postingListMapping.put(docIds, i);
        for (int docId : docIds) {
            bitVector[docId] |= (1 << i);
        }
    }
    return new CachedPostingListCounter(postingListMapping, bitVector);
}
 
示例3
public void setNameToPositionMap(ObjectIntMap<String> map)
{
    this.nameToPositionMap = new ObjectIntHashMap(map.size());
    map.forEachKeyValue(new ObjectIntProcedure<String>()
    {
        @Override
        public void value(String each, int parameter)
        {
            nameToPositionMap.put(each, parameter);
        }
    });
}
 
示例4
@Override
public int test() {
    final ObjectIntHashMap<Integer> m_map = new ObjectIntHashMap<>( m_keys.length );
    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();
}
 
示例5
@Override
public int test() {
    final ObjectIntHashMap<Integer> m_map = new ObjectIntHashMap<>( m_keys.length / 2 + 1 );
    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();
}
 
示例6
/**
 * @return mapping of item IDs to count of users that have interacted with that item
 */
public Map<String,Integer> getItemCounts() {
  ObjectIntHashMap<String> counts = ObjectIntHashMap.newMap();
  try (AutoLock al = knownItemsLock.autoReadLock()) {
    knownItems.values().forEach(ids -> {
      synchronized (ids) {
        ids.forEach(id -> counts.addToValue(id, 1));
      }
    });
  }
  // No way to get Java map from primitive map directly (?)
  Map<String,Integer> javaCounts = new HashMap<>(counts.size());
  counts.forEachKeyValue(javaCounts::put);
  return javaCounts;
}
 
示例7
public PartitionedFeatureVectors(int numPartitions,
                                 ExecutorService executor,
                                 ToIntBiFunction<String,float[]> partitioner) {
  Preconditions.checkArgument(numPartitions > 0);
  Objects.requireNonNull(executor);
  Objects.requireNonNull(partitioner);
  partitions = new FeatureVectorsPartition[numPartitions];
  for (int i = 0; i < numPartitions; i++) {
    partitions[i] = new FeatureVectorsPartition();
  }
  partitionMap = ObjectIntHashMap.newMap();
  partitionMapLock = new AutoReadWriteLock();
  this.partitioner = partitioner;
  this.executor = executor;
}
 
示例8
public CachedPostingListCounter(int nDocuments) {
    this.nDocuments = nDocuments;
    this.postingListMapping = new ObjectIntHashMap<>();
    this.bitVector = new int[0];
}
 
示例9
private CachedPostingListCounter(ObjectIntHashMap<int[]> postingListMapping, int[] bitVector) {
    this.nDocuments = bitVector.length;
    this.postingListMapping = postingListMapping;
    this.bitVector = bitVector;
}
 
示例10
ObjectIntHashMap<int[]> getPostingListMapping() {
    return postingListMapping;
}
 
示例11
@Override
public void setup(int[] keys, float fillFactor, final int oneFailureOutOf ) {
    super.setup(keys, fillFactor, oneFailureOutOf);
    m_map = new ObjectIntHashMap<>( keys.length );
    for ( Integer key : keys ) m_map.put( new Integer( key % oneFailureOutOf == 0 ? key + 1 : key), key );
}