Java 类gnu.trove.map.TIntIntMap 实例源码

项目:xcc    文件:TIntIntHashMap.java   
/**
 * Creates a new <code>TIntIntHashMap</code> instance containing
 * all of the entries in the map passed in.
 *
 * @param map a <tt>TIntIntMap</tt> that will be duplicated.
 */
public TIntIntHashMap( TIntIntMap map ) {
    super( map.size() );
    if ( map instanceof TIntIntHashMap ) {
        TIntIntHashMap hashmap = ( TIntIntHashMap ) map;
        this._loadFactor = hashmap._loadFactor;
        this.no_entry_key = hashmap.no_entry_key;
        this.no_entry_value = hashmap.no_entry_value;
        //noinspection RedundantCast
        if ( this.no_entry_key != ( int ) 0 ) {
            Arrays.fill( _set, this.no_entry_key );
        }
        //noinspection RedundantCast
        if ( this.no_entry_value != ( int ) 0 ) {
            Arrays.fill( _values, this.no_entry_value );
        }
        setUp( (int) Math.ceil( DEFAULT_CAPACITY / _loadFactor ) );
    }
    putAll( map );
}
项目:HCFCore    文件:TIntIntHashMap.java   
/**
 * Creates a new <code>TIntIntHashMap</code> instance containing
 * all of the entries in the map passed in.
 *
 * @param map a <tt>TIntIntMap</tt> that will be duplicated.
 */
public TIntIntHashMap( TIntIntMap map ) {
    super( map.size() );
    if ( map instanceof TIntIntHashMap ) {
        TIntIntHashMap hashmap = ( TIntIntHashMap ) map;
        this._loadFactor = hashmap._loadFactor;
        this.no_entry_key = hashmap.no_entry_key;
        this.no_entry_value = hashmap.no_entry_value;
        //noinspection RedundantCast
        if ( this.no_entry_key != ( int ) 0 ) {
            Arrays.fill( _set, this.no_entry_key );
        }
        //noinspection RedundantCast
        if ( this.no_entry_value != ( int ) 0 ) {
            Arrays.fill( _values, this.no_entry_value );
        }
        setUp( (int) Math.ceil( DEFAULT_CAPACITY / _loadFactor ) );
    }
    putAll( map );
}
项目:HCFCore    文件:TIntIntHashMap.java   
/**
 * Creates a new <code>TIntIntHashMap</code> instance containing
 * all of the entries in the map passed in.
 *
 * @param map a <tt>TIntIntMap</tt> that will be duplicated.
 */
public TIntIntHashMap( TIntIntMap map ) {
    super( map.size() );
    if ( map instanceof TIntIntHashMap ) {
        TIntIntHashMap hashmap = ( TIntIntHashMap ) map;
        this._loadFactor = hashmap._loadFactor;
        this.no_entry_key = hashmap.no_entry_key;
        this.no_entry_value = hashmap.no_entry_value;
        //noinspection RedundantCast
        if ( this.no_entry_key != ( int ) 0 ) {
            Arrays.fill( _set, this.no_entry_key );
        }
        //noinspection RedundantCast
        if ( this.no_entry_value != ( int ) 0 ) {
            Arrays.fill( _values, this.no_entry_value );
        }
        setUp( (int) Math.ceil( DEFAULT_CAPACITY / _loadFactor ) );
    }
    putAll( map );
}
项目:trove-3.0.3    文件:TPrimitivePrimitiveOffheapHashMapTest.java   
public void testEquals() {
    int[] keys = {1138, 42, 86, 99, 101, 727, 117};
    long[] vals = new long[keys.length];

    TIntLongMap map = new TIntLongOffheapHashMap();
    for ( int i = 0; i < keys.length; i++ ) {
        vals[i] = keys[i] * 2;
        map.put( keys[i], vals[i] );
    }
    assertEquals( map, map );

    TIntIntMap int_map = new TIntIntOffheapHashMap();
    for ( int i = 0; i < keys.length; i++ ) {
        int_map.put( keys[i], (int) vals[i] );
    }
    assertFalse( map.equals( int_map ) );
}
项目:trove-3.0.3    文件:TIntIntHashMap.java   
/**
 * Creates a new <code>TIntIntHashMap</code> instance containing
 * all of the entries in the map passed in.
 *
 * @param map a <tt>TIntIntMap</tt> that will be duplicated.
 */
public TIntIntHashMap( TIntIntMap map ) {
    super( map.size() );
    if ( map instanceof TIntIntHashMap ) {
        TIntIntHashMap hashmap = ( TIntIntHashMap ) map;
        this._loadFactor = hashmap._loadFactor;
        this.no_entry_key = hashmap.no_entry_key;
        this.no_entry_value = hashmap.no_entry_value;
        //noinspection RedundantCast
        if ( this.no_entry_key != ( int ) 0 ) {
            Arrays.fill( _set, this.no_entry_key );
        }
        //noinspection RedundantCast
        if ( this.no_entry_value != ( int ) 0 ) {
            Arrays.fill( _values, this.no_entry_value );
        }
        setUp( (int) Math.ceil( DEFAULT_CAPACITY / _loadFactor ) );
    }
    putAll( map );
}
项目:Avaritiaddons    文件:TileEntityExtremeAutoCrafter.java   
private void cleanInput()
{
    final TIntIntMap patternMap = new TIntIntHashMap(this.patternMap);
    for (int i = 0; i < 81 && !patternMap.isEmpty(); i++) {
        final ItemStack itemStack = itemStacks[i];
        final int key = MetaItem.get(itemStack);
        if (patternMap.containsKey(key)) {
            final int total = patternMap.get(key);
            final int dif = MathHelper.clamp_int(total, 1, itemStack.stackSize);
            if (!itemStack.getItem().hasContainerItem(itemStack))
                itemStack.stackSize -= dif;
            if (dif - total == 0)
                patternMap.remove(key);
            else
                patternMap.put(key, total - dif);
            if (itemStack.stackSize == 0)
                itemStacks[i] = null;
        }
    }
}
项目:TopPI    文件:SparseCounters.java   
private SparseCounters(int minSupport, int transactionsCount, int distinctTransactionsCount,
        int distinctTransactionLengthSum, TIntIntMap supportCounts, TIntIntMap distinctTransactionsCounts,
        int[] closure, int[] pattern, int nbFrequents, int maxFrequent, int[] reverseRenaming,
        boolean compactedArrays, int maxCandidate, int rebasingSize) {
    super();
    this.minSupport = minSupport;
    this.transactionsCount = transactionsCount;
    this.distinctTransactionsCount = distinctTransactionsCount;
    this.distinctTransactionLengthSum = distinctTransactionLengthSum;
    this.supportCounts = supportCounts;
    this.distinctTransactionsCounts = distinctTransactionsCounts;
    this.closure = closure;
    this.pattern = pattern;
    this.nbFrequents = nbFrequents;
    this.maxFrequent = maxFrequent;
    this.reverseRenaming = reverseRenaming;
    this.compactedArrays = compactedArrays;
    this.maxCandidate = maxCandidate;
    this.rebasingSize = rebasingSize;
}
项目:TopPI    文件:DistCache.java   
private static TIntIntMap readIntIntMap(URI[] files, Configuration conf, String token, int size) throws IOException {
    TIntIntMap map = new TIntIntHashMap(size, Constants.DEFAULT_LOAD_FACTOR, -1, -1);
    for (URI file : files) {
        if (file.getPath().contains(token)) {
            SequenceFile.Reader reader = new SequenceFile.Reader(conf, Reader.file(new Path(file)));
            IntWritable key = new IntWritable();
            IntWritable value = new IntWritable();

            while (reader.next(key, value)) {
                map.put(key.get(), value.get());
            }

            reader.close();
        }
    }

    return map;
}
项目:TopPI    文件:PerItemTopKCollector.java   
public final TIntIntMap getTopKBounds() {
    final TIntIntMap output = new TIntIntHashMap(this.topK.size());
    this.topK.forEachEntry(new TIntObjectProcedure<PatternWithFreq[]>() {

        @Override
        public boolean execute(int k, PatternWithFreq[] v) {
            int s;
            PatternWithFreq p = v[v.length - 1];
            if (p == null) {
                s = -1;
            } else if (p.isClosed()) {
                s = p.getSupportCount() + 1;
            } else {
                s = p.getSupportCount();
            }
            output.put(k, s);
            return true;
        }
    });
    return output;
}
项目:easyrec_major    文件:TIntIntHashMap.java   
/**
 * Creates a new <code>TIntIntHashMap</code> instance containing
 * all of the entries in the map passed in.
 *
 * @param map a <tt>TIntIntMap</tt> that will be duplicated.
 */
public TIntIntHashMap( TIntIntMap map ) {
    super( map.size() );
    if ( map instanceof TIntIntHashMap ) {
        TIntIntHashMap hashmap = ( TIntIntHashMap ) map;
        this._loadFactor = hashmap._loadFactor;
        this.no_entry_key = hashmap.no_entry_key;
        this.no_entry_value = hashmap.no_entry_value;
        //noinspection RedundantCast
        if ( this.no_entry_key != ( int ) 0 ) {
            Arrays.fill( _set, this.no_entry_key );
        }
        //noinspection RedundantCast
        if ( this.no_entry_value != ( int ) 0 ) {
            Arrays.fill( _values, this.no_entry_value );
        }
        setUp( (int) Math.ceil( DEFAULT_CAPACITY / _loadFactor ) );
    }
    putAll( map );
}
项目:recalot.com    文件:TIntIntHashMap.java   
/**
 * Creates a new <code>TIntIntHashMap</code> instance containing
 * all of the entries in the map passed in.
 *
 * @param map a <tt>TIntIntMap</tt> that will be duplicated.
 */
public TIntIntHashMap( TIntIntMap map ) {
    super( map.size() );
    if ( map instanceof TIntIntHashMap ) {
        TIntIntHashMap hashmap = ( TIntIntHashMap ) map;
        this._loadFactor = hashmap._loadFactor;
        this.no_entry_key = hashmap.no_entry_key;
        this.no_entry_value = hashmap.no_entry_value;
        //noinspection RedundantCast
        if ( this.no_entry_key != ( int ) 0 ) {
            Arrays.fill( _set, this.no_entry_key );
        }
        //noinspection RedundantCast
        if ( this.no_entry_value != ( int ) 0 ) {
            Arrays.fill( _values, this.no_entry_value );
        }
        setUp( (int) Math.ceil( DEFAULT_CAPACITY / _loadFactor ) );
    }
    putAll( map );
}
项目:easyrec-PoC    文件:TIntIntHashMap.java   
/**
 * Creates a new <code>TIntIntHashMap</code> instance containing
 * all of the entries in the map passed in.
 *
 * @param map a <tt>TIntIntMap</tt> that will be duplicated.
 */
public TIntIntHashMap( TIntIntMap map ) {
    super( map.size() );
    if ( map instanceof TIntIntHashMap ) {
        TIntIntHashMap hashmap = ( TIntIntHashMap ) map;
        this._loadFactor = hashmap._loadFactor;
        this.no_entry_key = hashmap.no_entry_key;
        this.no_entry_value = hashmap.no_entry_value;
        //noinspection RedundantCast
        if ( this.no_entry_key != ( int ) 0 ) {
            Arrays.fill( _set, this.no_entry_key );
        }
        //noinspection RedundantCast
        if ( this.no_entry_value != ( int ) 0 ) {
            Arrays.fill( _values, this.no_entry_value );
        }
        setUp( (int) Math.ceil( DEFAULT_CAPACITY / _loadFactor ) );
    }
    putAll( map );
}
项目:pre-cu    文件:SlottedContainerService.java   
private boolean internalDoSlottedAdd(final SlottedContainer container,
                                     final GameObject item,
                                     final int position,
                                     final int arrangementIndex) {
    if (arrangementIndex < 0)
        return false;

    final SlottedContainmentProperty slottedProperty = item.getProperty(SlottedContainmentProperty.getClassPropertyId());
    final int numSlots = slottedProperty.getNumberOfSlots(arrangementIndex);
    final TIntIntMap slotMap = ReflectionUtil.getFieldValue(slotMapField, container);

    for (int i = 0; i < numSlots; ++i) {
        final int slotId = slottedProperty.getSlotId(arrangementIndex, i);

        if (!slotMap.containsKey(slotId)) {
            LOGGER.error("We're trying to add an item to a slotted container that does not have a slot that this item {} with this arrangement {} can go into or has something in it already.",
                    item.getNetworkId(),
                    arrangementIndex);
        } else {
            slotMap.put(slotId, position);
        }
    }

    return true;
}
项目:pre-cu    文件:SlottedContainerService.java   
public int findFirstSlotIdForObject(final SlottedContainer container, final GameObject item) {
    final ContainerResult containerResult = new ContainerResult();
    final int position = containerService.find(container, item, containerResult);

    if (position >= 0) {
        final TIntIntMap slotMap = ReflectionUtil.getFieldValue(slotMapField, container);
        final int[] keys = slotMap.keys();

        for (int i = 0, size = keys.length; i < size; ++i) {
            final int objPosition = slotMap.get(keys[i]);

            if (objPosition == position)
                return keys[i];
        }
    }

    return SlotId.INVALID;
}
项目:pre-cu    文件:SlottedContainerService.java   
private boolean internalRemove(final SlottedContainer container, final GameObject item, final int overrideArrangement) {
    final ContainerResult containerResult = new ContainerResult();

    final int position = containerService.find(container, item, containerResult);

    if (position == -1) {
        LOGGER.warn("called with an invalid item: container owner id={}, template={}; item id={}, template={}",
                container.getOwner().getNetworkId(),
                container.getOwner().getObjectTemplateName(),
                item.getNetworkId(),
                item.getObjectTemplateName());
        return false;
    }

    final TIntIntMap slotMap = ReflectionUtil.getFieldValue(slotMapField, container);
    final int[] keys = slotMap.keys();

    for (int i = 0, size = keys.length; i < size; ++i) {
        final int pos = slotMap.get(keys[i]);

        if (pos == position)
            slotMap.put(i, -1); //Pretty sure we should be able to do this more efficiently.
    }

    return true;
}
项目:easyrec    文件:TIntIntHashMap.java   
/**
 * Creates a new <code>TIntIntHashMap</code> instance containing
 * all of the entries in the map passed in.
 *
 * @param map a <tt>TIntIntMap</tt> that will be duplicated.
 */
public TIntIntHashMap( TIntIntMap map ) {
    super( map.size() );
    if ( map instanceof TIntIntHashMap ) {
        TIntIntHashMap hashmap = ( TIntIntHashMap ) map;
        this._loadFactor = hashmap._loadFactor;
        this.no_entry_key = hashmap.no_entry_key;
        this.no_entry_value = hashmap.no_entry_value;
        //noinspection RedundantCast
        if ( this.no_entry_key != ( int ) 0 ) {
            Arrays.fill( _set, this.no_entry_key );
        }
        //noinspection RedundantCast
        if ( this.no_entry_value != ( int ) 0 ) {
            Arrays.fill( _values, this.no_entry_value );
        }
        setUp( (int) Math.ceil( DEFAULT_CAPACITY / _loadFactor ) );
    }
    putAll( map );
}
项目:RPG-Items-2    文件:TIntIntHashMap.java   
/**
 * Creates a new <code>TIntIntHashMap</code> instance containing
 * all of the entries in the map passed in.
 *
 * @param map a <tt>TIntIntMap</tt> that will be duplicated.
 */
public TIntIntHashMap( TIntIntMap map ) {
    super( map.size() );
    if ( map instanceof TIntIntHashMap ) {
        TIntIntHashMap hashmap = ( TIntIntHashMap ) map;
        this._loadFactor = hashmap._loadFactor;
        this.no_entry_key = hashmap.no_entry_key;
        this.no_entry_value = hashmap.no_entry_value;
        //noinspection RedundantCast
        if ( this.no_entry_key != ( int ) 0 ) {
            Arrays.fill( _set, this.no_entry_key );
        }
        //noinspection RedundantCast
        if ( this.no_entry_value != ( int ) 0 ) {
            Arrays.fill( _values, this.no_entry_value );
        }
        setUp( (int) Math.ceil( DEFAULT_CAPACITY / _loadFactor ) );
    }
    putAll( map );
}
项目:xcc    文件:TIntIntHashMap.java   
/** {@inheritDoc} */
public void putAll( TIntIntMap map ) {
    ensureCapacity( map.size() );
    TIntIntIterator iter = map.iterator();
    while ( iter.hasNext() ) {
        iter.advance();
        this.put( iter.key(), iter.value() );
    }
}
项目:xcc    文件:TIntIntHashMap.java   
/** {@inheritDoc} */
@Override
public boolean equals( Object other ) {
    if ( ! ( other instanceof TIntIntMap ) ) {
        return false;
    }
    TIntIntMap that = ( TIntIntMap ) other;
    if ( that.size() != this.size() ) {
        return false;
    }
    int[] values = _values;
    byte[] states = _states;
    int this_no_entry_value = getNoEntryValue();
    int that_no_entry_value = that.getNoEntryValue();
    for ( int i = values.length; i-- > 0; ) {
        if ( states[i] == FULL ) {
            int key = _set[i];
            int that_value = that.get( key );
            int this_value = values[i];
            if ( ( this_value != that_value ) &&
                 ( this_value != this_no_entry_value ) &&
                 ( that_value != that_no_entry_value ) ) {
                return false;
            }
        }
    }
    return true;
}
项目:xcc    文件:TIntIntMapDecorator.java   
public void readExternal( ObjectInput in )
    throws IOException, ClassNotFoundException {

    // VERSION
    in.readByte();

    // MAP
    _map = ( TIntIntMap ) in.readObject();
}
项目:HCFCore    文件:TIntIntHashMap.java   
/** {@inheritDoc} */
public void putAll( TIntIntMap map ) {
    ensureCapacity( map.size() );
    TIntIntIterator iter = map.iterator();
    while ( iter.hasNext() ) {
        iter.advance();
        this.put( iter.key(), iter.value() );
    }
}
项目:HCFCore    文件:TIntIntHashMap.java   
/** {@inheritDoc} */
@Override
public boolean equals( Object other ) {
    if ( ! ( other instanceof TIntIntMap ) ) {
        return false;
    }
    TIntIntMap that = ( TIntIntMap ) other;
    if ( that.size() != this.size() ) {
        return false;
    }
    int[] values = _values;
    byte[] states = _states;
    int this_no_entry_value = getNoEntryValue();
    int that_no_entry_value = that.getNoEntryValue();
    for ( int i = values.length; i-- > 0; ) {
        if ( states[i] == FULL ) {
            int key = _set[i];
            int that_value = that.get( key );
            int this_value = values[i];
            if ( ( this_value != that_value ) &&
                 ( this_value != this_no_entry_value ) &&
                 ( that_value != that_no_entry_value ) ) {
                return false;
            }
        }
    }
    return true;
}
项目:HCFCore    文件:TIntIntMapDecorator.java   
public void readExternal( ObjectInput in )
    throws IOException, ClassNotFoundException {

    // VERSION
    in.readByte();

    // MAP
    _map = ( TIntIntMap ) in.readObject();
}
项目:HCFCore    文件:TIntIntHashMap.java   
/** {@inheritDoc} */
public void putAll( TIntIntMap map ) {
    ensureCapacity( map.size() );
    TIntIntIterator iter = map.iterator();
    while ( iter.hasNext() ) {
        iter.advance();
        this.put( iter.key(), iter.value() );
    }
}
项目:HCFCore    文件:TIntIntHashMap.java   
/** {@inheritDoc} */
@Override
public boolean equals( Object other ) {
    if ( ! ( other instanceof TIntIntMap ) ) {
        return false;
    }
    TIntIntMap that = ( TIntIntMap ) other;
    if ( that.size() != this.size() ) {
        return false;
    }
    int[] values = _values;
    byte[] states = _states;
    int this_no_entry_value = getNoEntryValue();
    int that_no_entry_value = that.getNoEntryValue();
    for ( int i = values.length; i-- > 0; ) {
        if ( states[i] == FULL ) {
            int key = _set[i];
            int that_value = that.get( key );
            int this_value = values[i];
            if ( ( this_value != that_value ) &&
                 ( this_value != this_no_entry_value ) &&
                 ( that_value != that_no_entry_value ) ) {
                return false;
            }
        }
    }
    return true;
}
项目:HCFCore    文件:TIntIntMapDecorator.java   
public void readExternal( ObjectInput in )
    throws IOException, ClassNotFoundException {

    // VERSION
    in.readByte();

    // MAP
    _map = ( TIntIntMap ) in.readObject();
}
项目:trove-3.0.3    文件:TPrimitivePrimitiveHashMapTest.java   
public void testEquals() {
    int[] keys = {1138, 42, 86, 99, 101, 727, 117};
    long[] vals = new long[keys.length];

    TIntLongMap map = new TIntLongHashMap();
    for ( int i = 0; i < keys.length; i++ ) {
        vals[i] = keys[i] * 2;
        map.put( keys[i], vals[i] );
    }
    assertEquals( map, map );

    TIntIntMap int_map = new TIntIntHashMap();
    for ( int i = 0; i < keys.length; i++ ) {
        int_map.put( keys[i], (int) vals[i] );
    }
    assertFalse( map.equals( int_map ) );

    // Change a value..
    TIntLongMap unequal = new TIntLongHashMap( map );
    map.put( keys[3], vals[3] + 1 );
    assertFalse( map.equals( unequal ) );

    // Change length
    unequal = new TIntLongHashMap( map );
    map.put( 13, 26 );
    assertFalse( map.equals( unequal ) );
}
项目:trove-3.0.3    文件:TIntIntOffheapHashMap.java   
/** {@inheritDoc} */
@Override
public void putAll( TIntIntMap map ) {
    ensureCapacity( map.size() );
    TIntIntIterator iter = map.iterator();
    while ( iter.hasNext() ) {
        iter.advance();
        this.put( iter.key(), iter.value() );
    }
}
项目:trove-3.0.3    文件:TIntIntOffheapHashMap.java   
/** {@inheritDoc} */
@Override
public boolean equals( Object other ) {
    if ( ! ( other instanceof TIntIntMap ) ) {
        return false;
    }
    TIntIntMap that = ( TIntIntMap ) other;
    if ( that.size() != this.size() ) {
        return false;
    }
    TIntOffheapArray values = _values;
    TByteOffheapArray states = _states;
    int this_no_entry_value = getNoEntryValue();
    int that_no_entry_value = that.getNoEntryValue();
    for ( int i = capacity(); i-- > 0; ) {
        if ( states.get( i ) == FULL ) {
            int key = _set.get( i );
            int that_value = that.get( key );
            int this_value = values.get( i );
            if ( ( this_value != that_value ) &&
                 ( this_value != this_no_entry_value ) &&
                 ( that_value != that_no_entry_value ) ) {
                return false;
            }
        }
    }
    return true;
}
项目:trove-3.0.3    文件:TIntIntHashMap.java   
/** {@inheritDoc} */
@Override
public void putAll( TIntIntMap map ) {
    ensureCapacity( map.size() );
    TIntIntIterator iter = map.iterator();
    while ( iter.hasNext() ) {
        iter.advance();
        this.put( iter.key(), iter.value() );
    }
}
项目:trove-3.0.3    文件:TIntIntHashMap.java   
/** {@inheritDoc} */
@Override
public boolean equals( Object other ) {
    if ( ! ( other instanceof TIntIntMap ) ) {
        return false;
    }
    TIntIntMap that = ( TIntIntMap ) other;
    if ( that.size() != this.size() ) {
        return false;
    }
    int[] values = _values;
    byte[] states = _states;
    int this_no_entry_value = getNoEntryValue();
    int that_no_entry_value = that.getNoEntryValue();
    for ( int i = values.length; i-- > 0; ) {
        if ( states[i] == FULL ) {
            int key = _set[i];
            int that_value = that.get( key );
            int this_value = values[i];
            if ( ( this_value != that_value ) &&
                 ( this_value != this_no_entry_value ) &&
                 ( that_value != that_no_entry_value ) ) {
                return false;
            }
        }
    }
    return true;
}
项目:trove-3.0.3    文件:TIntIntMapDecorator.java   
@Override
public void readExternal( ObjectInput in )
    throws IOException, ClassNotFoundException {

    // VERSION
    in.readByte();

    // MAP
    _map = ( TIntIntMap ) in.readObject();
}
项目:monsoon    文件:MetricTable.java   
private static mt_32bit encode32Bit(TIntIntMap t_32bit, int timestampsSize) {
    LOG.log(Level.FINEST, "encoding {0}", TDecorators.wrap(t_32bit));
    int[] values = new int[timestampsSize];
    int values_len = 0;
    for (int i = 0; i < values.length; ++i) {
        if (t_32bit.containsKey(i))
            values[values_len++] = t_32bit.get(i);
    }

    mt_32bit result = new mt_32bit();
    result.presence = createPresenceBitset(t_32bit.keySet(), timestampsSize);
    result.values = Arrays.copyOf(values, values_len);

    return result;
}
项目:monsoon    文件:MetricTable.java   
private static mt_str encodeStr(TIntIntMap t_str, int timestampsSize) {
    LOG.log(Level.FINEST, "encoding {0}", TDecorators.wrap(t_str));
    int[] values = new int[timestampsSize];
    int values_len = 0;
    for (int i = 0; i < values.length; ++i) {
        if (t_str.containsKey(i))
            values[values_len++] = t_str.get(i);
    }

    mt_str result = new mt_str();
    result.presence = createPresenceBitset(t_str.keySet(), timestampsSize);
    result.values = Arrays.copyOf(values, values_len);

    return result;
}
项目:Avaritiaddons    文件:TileEntityExtremeAutoCrafter.java   
private boolean matches(@Nonnull final TIntIntMap inputMap, @Nonnull final TIntIntMap patternMap)
{
    if (inputMap.size() >= patternMap.size() && inputMap.keySet().containsAll(patternMap.keySet())) {
        for (final int key : patternMap.keys())
            if (inputMap.get(key) < patternMap.get(key))
                return false;
        return true;
    } else
        return false;
}
项目:TopPI    文件:MapTidList.java   
public MapTidList(final TIntIntMap lengths) {
    TIntIntIterator iter = lengths.iterator();
    while (iter.hasNext()) {
        iter.advance();
        this.occurrences.put(iter.key(), new TIntArrayList(iter.value()));
    }
}
项目:TopPI    文件:PerItemTopKHadoopCollector.java   
public void preloadBounds(TIntIntMap perItemBounds) {
    TIntIntIterator iterator = perItemBounds.iterator();
    int[] fakePattern = new int[] { };
    while (iterator.hasNext()) {
        iterator.advance();

        final int item = iterator.key();
        PatternWithFreq[] top = this.topK.get(item);

        if (top != null) {
            Arrays.fill(top, new PatternWithFreq(iterator.value(), fakePattern, true));
        }
    }
}
项目:TopPI    文件:FileFilteredReader.java   
public FileFilteredReader(final URI path, TIntIntMap globalRenaming, SingleGroup filter) {
    try {
        inBuffer = new BufferedReaderWrapper(new BufferedReader(new java.io.FileReader(new File(path))));
        nextChar = inBuffer.read();
        initRenaming = globalRenaming;
        grouper = filter;

        newPage();
        preReadNext();
    } catch (Exception e) {
        e.printStackTrace();
        System.exit(1);
    }
}
项目:TopPI    文件:FileFilteredReader.java   
public FileFilteredReader(FSDataInputStream inputStream, TIntIntMap globalRenaming, SingleGroup filter) {
    try {
        inBuffer = new HDFSWrapper(inputStream);
        nextChar = inBuffer.read();
        initRenaming = globalRenaming;
        grouper = filter;

        newPage();
    } catch (Exception e) {
        e.printStackTrace();
        System.exit(1);
    }
}
项目:TopPI    文件:FileReaderTest.java   
@Test
public void testFilteredReader() {
    int groupsCount = 2;
    int maxItem = 4;
    int singleGroupID = 1;

    SingleGroup filter = new SingleGroup(groupsCount, maxItem, singleGroupID);

    TIntIntMap renaming = new TIntIntHashMap();
    renaming.put(1, 3);
    renaming.put(2, -1);
    renaming.put(3, 2);
    renaming.put(5, 1);
    renaming.put(6, 4);
    renaming.put(7, 0);
    FileFilteredReader reader = null;
    reader = new FileFilteredReader(new File(PATH_MICRO).toURI(), renaming, filter);
    assertTrue(reader.hasNext());
    readLine(reader.next(), 1, 2, 3, 4, 0);
    readLine(reader.next(), 1, 2, 3, 4);
    readLine(reader.next(), 1, 0);
    // readLine(reader.next(), 0,2); filtered !
    readLine(reader.next(), 1, 2, 3, 4, 0);
    assertFalse(reader.hasNext());

    reader.close(new int[] { -1, 0, -1, -1, -1 });
    assertTrue(reader.hasNext());
    readLine(reader.next(), 0);
    readLine(reader.next(), 0);
    readLine(reader.next(), 0);
    readLine(reader.next(), 0);
    assertFalse(reader.hasNext());
}