Package gnu.trove.map

Examples of gnu.trove.map.TIntIntMap


        }
        if (isContiguous)
            return g;       

        // Map the vertices to a contiguous range
        TIntIntMap vMap = new TIntIntHashMap(g.order());
        int j = 0;
        for (int i : g.vertices())
            vMap.put(i, j++);
       
        Graph<E> copy = g.copy(Collections.<Integer>emptySet());
        for (int i = 0; i < order; ++i)
            copy.add(i);
        for (E e : g.edges())
            copy.add(e.<E>clone(vMap.get(e.from()), vMap.get(e.to())));
       
        return copy;
    }   
View Full Code Here


        // If we mapped the vertices, we have to unmap the vertices in order
        // to identify the isometric pairs.
        if (match(state, isoMapping)) {
            // Create a new isometric map that will contain the unmapped
            // mappings
            TIntIntMap fixedIsoMapping = new TIntIntHashMap(isoMapping.size());
            for (Map.Entry<Integer,Integer> e : isoMapping.entrySet()) {
                int v1 = e.getKey();
                v1 = (g1vMap.isEmpty()) ? v1 : g1vMap.get(v1);
                int v2 = e.getValue();
                v2 = (g2vMap.isEmpty()) ? v2 : g2vMap.get(v2);
                fixedIsoMapping.put(v1, v2);
            }
            return TDecorators.wrap(fixedIsoMapping);
        }
        else
            return Collections.<Integer,Integer>emptyMap();
View Full Code Here

        }
        if (isContiguous)
            return g;       

        // Map the vertices to a contiguous range
        TIntIntMap vMap = new TIntIntHashMap(g.order());
        int j = 0;
        for (int i : g.vertices()) {
            vMap.put(i, j++);
        }
       
        if (rvMap != null) {
            // Assumes a stable iteration ordering of the vertices, which is
            // potentially unsafe... However, this avoids putting a redundant
            // null check in the prior loop.
            int k = 0;
            for (int i : g.vertices()) {
                rvMap.put(k++, i);
            }
        }
       
        Graph<E> copy = g.copy(Collections.<Integer>emptySet());
        for (int i = 0; i < order; ++i)
            copy.add(i);
        for (E e : g.edges())
            copy.add(e.<E>clone(vMap.get(e.from()), vMap.get(e.to())));
       
        return copy;
    }   
View Full Code Here

        // If the state of this set's type is inconsistent with the current type
        // mapping, then update the mapping with any missing types and then
        // reset all of its BitSet contents with the correct indices
        if (needToRemapIndices) {
            TIntIntMap typeRemapping = new TIntIntHashMap();
            for (Map.Entry<Object,Integer> e : typeIndices.entrySet()) {
                Object o = e.getKey();
                int oldIndex = e.getValue();
                // NOTE: the else {} case above may have added several of our
                // types that weren't inconsistent, so this may be an identity
                // mapping for some types, which is nice.
                typeRemapping.put(oldIndex, index(o));
            }
            // Remap all the in-edges vertices' types...
            for (TIntObjectIterator<BitSet> it = edges.iterator(); it.hasNext(); ) {
                it.advance();
                int v = it.key();
                BitSet oldIndices = it.value();
                BitSet newIndices = new BitSet();
                for (int i = oldIndices.nextSetBit(0); i >= 0;
                         i = oldIndices.nextSetBit(i+1)) {
                    newIndices.set(typeRemapping.get(i));
                }
                it.setValue(newIndices);
            }
        }
    }
View Full Code Here

        // If the state of this set's type is inconsistent with the current type
        // mapping, then update the mapping with any missing types and then
        // reset all of its BitSet contents with the correct indices
        if (needToRemapIndices) {
            TIntIntMap typeRemapping = new TIntIntHashMap();
            for (Map.Entry<Object,Integer> e : typeIndices.entrySet()) {
                Object o = e.getKey();
                int oldIndex = e.getValue();
                // NOTE: the else {} case above may have added several of our
                // types that weren't inconsistent, so this may be an identity
                // mapping for some types, which is nice.
                typeRemapping.put(oldIndex, index(o));
            }
            // Remap all the in-edges vertices' types...
            for (TIntObjectIterator<BitSet> it = inEdges.iterator(); it.hasNext(); ) {
                it.advance();
                int v = it.key();
                BitSet oldIndices = it.value();
                BitSet newIndices = new BitSet();
                for (int i = oldIndices.nextSetBit(0); i >= 0;
                         i = oldIndices.nextSetBit(i+1)) {
                    newIndices.set(typeRemapping.get(i));
                }
                it.setValue(newIndices);
            }
            // Remap all the in-edges vertices' types...
            for (TIntObjectIterator<BitSet> it = outEdges.iterator(); it.hasNext(); ) {
                it.advance();
                int v = it.key();
                BitSet oldIndices = it.value();
                BitSet newIndices = new BitSet();
                for (int i = oldIndices.nextSetBit(0); i >= 0;
                         i = oldIndices.nextSetBit(i+1)) {
                    newIndices.set(typeRemapping.get(i));
                }
                it.setValue(newIndices);
            }
        }
    }
View Full Code Here

    @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;
View Full Code Here

        public void write(Kryo kryo, Output output, DenseVectorSet vectorSet) {
            output.writeString(vectorSet.key());
            kryo.writeObject(output, vectorSet.accumuFactor);
            kryo.writeObject(output, vectorSet.sparseFactor);

            TIntIntMap indexer = vectorSet.indexer;
            TIntIntIterator iter = indexer.iterator();
            kryo.writeObject(output, indexer.size());
            while (iter.hasNext()) {
                iter.advance();
                int vecid = iter.key();
                int start = iter.value();
                int length = vectorSet.length(vecid);
View Full Code Here

        public void write(Kryo kryo, Output output, SparseVectorSet vectorSet) {
            output.writeString(vectorSet.key());
            kryo.writeObject(output, vectorSet.accumuFactor);
            kryo.writeObject(output, vectorSet.sparseFactor);

            TIntIntMap indexer = vectorSet.indexer;
            TIntIntIterator iter = indexer.iterator();
            kryo.writeObject(output, indexer.size());
            while (iter.hasNext()) {
                iter.advance();
                int vecid = iter.key();
                int start = iter.value();
                int length = vectorSet.length(vecid);
View Full Code Here

            raw_map.put( keys[i], vals[i] );
        }
        Map<Integer,Long> map = TDecorators.wrap( raw_map );
        assertEquals( map, map );

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

        // Change a value..
View Full Code Here

    }

    @Override
    public void clean() {
        TFloatList olddata = data;
        TIntIntMap oldindexer = indexer;
        data = new TFloatArrayList(olddata.size());
        indexer = new TIntIntHashMap(oldindexer.size());

        int pos = 0;
        TIntIntIterator iter = oldindexer.iterator();
        while (iter.hasNext()) {
            iter.advance();
            int vecid = iter.key();
            int start = iter.value();
            int length = lengths.get(vecid);
View Full Code Here

TOP

Related Classes of gnu.trove.map.TIntIntMap

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.