Package gnu.trove.list.array

Examples of gnu.trove.list.array.TIntArrayList


    this(sortOrder, 10);
  }

  public PriorityQueue(boolean sortOrder, int initialCapacity) {
    this.sortOrder = sortOrder;
    values = new TIntArrayList(initialCapacity);
    priorities = new TFloatArrayList(initialCapacity);
  }
View Full Code Here


        assertFalse( keyset.isEmpty() );

        assertFalse( "keyset: " + keyset + ", should be unmodified.",
                keyset.retainAll( keyset ) );

        TIntCollection other = new TIntArrayList( keyset );
        assertFalse( "keyset: " + keyset + ", should be unmodified. other: " +
                     other, keyset.retainAll( other ) );

        other.remove( keys[5] );
        assertTrue( "keyset: " + keyset + ", should be modified. other: " +
                    other, keyset.retainAll( other ) );
        assertFalse( keyset.contains( keys[5] ) );
        assertFalse( map.containsKey( keys[5] ) );
        assertFalse( map.containsValue( vals[5] ) );
View Full Code Here

        for ( int i = 0; i < keyset.size(); i++ ) {
            assertTrue( keyset.contains( keys[i] ) );
        }
        assertFalse( keyset.isEmpty() );

        TIntCollection other = new TIntArrayList();
        assertFalse( "collection: " + keyset + ", should be unmodified.",
                keyset.removeAll( other ) );

        other = new TIntArrayList( keyset );
        other.remove( keys[5] );
        assertTrue( "collection: " + keyset + ", should be modified. other: " +
                    other, keyset.removeAll( other ) );
        assertEquals( 1, keyset.size() );
        for ( int i = 0; i < element_count; i++ ) {
            if ( i == 5 ) {
View Full Code Here

        assertEquals( element_count, map.size() );

        // No argument
        int[] keys_array = map.keys();
        assertEquals( element_count, keys_array.length );
        TIntList keys_list = new TIntArrayList( keys_array );
        for ( int i = 0; i < element_count; i++ ) {
            assertTrue( keys_list.contains( keys[i] ) );
        }

        // Zero length array
        keys_array = map.keys( new int[0] );
        assertEquals( element_count, keys_array.length );
        keys_list = new TIntArrayList( keys_array );
        for ( int i = 0; i < element_count; i++ ) {
            assertTrue( keys_list.contains( keys[i] ) );
        }

        // appropriate length array
        keys_array = map.keys( new int[map.size()] );
        assertEquals( element_count, keys_array.length );
        keys_list = new TIntArrayList( keys_array );
        for ( int i = 0; i < element_count; i++ ) {
            assertTrue( keys_list.contains( keys[i] ) );
        }

        // longer array
        keys_array = map.keys( new int[element_count * 2] );
        assertEquals( element_count * 2, keys_array.length );
        keys_list = new TIntArrayList( keys_array );
        for ( int i = 0; i < element_count; i++ ) {
            assertTrue( keys_list.contains( keys[i] ) );
        }
        assertEquals( map.getNoEntryKey(), keys_array[element_count] );
    }
View Full Code Here

        }
        assertEquals( element_count, map.size() );

        class ForEach implements TIntProcedure {

            TIntList built = new TIntArrayList();


            public boolean execute( int value ) {
                built.add( value );
                return true;
            }


            TIntList getBuilt() {
                return built;
            }
        }

        ForEach foreach = new ForEach();
        map.forEachKey( foreach );
        TIntList built = foreach.getBuilt();
        TIntList keys_list = new TIntArrayList( map.keys( new int[map.size()] ) );
        assertEquals( keys_list, built );

        built.sort();
        keys_list.sort();
        assertEquals( keys_list, built );


        class ForEachFalse implements TIntProcedure {

            TIntList built = new TIntArrayList();


            public boolean execute( int value ) {
                built.add( value );
                return false;
            }


            TIntList getBuilt() {
                return built;
            }
        }

        ForEachFalse foreach_false = new ForEachFalse();
        map.forEachKey( foreach_false );
        built = foreach_false.getBuilt();
        keys_list = new TIntArrayList( map.keys( new int[map.size()] ) );
        assertEquals( 1, built.size() );
        assertEquals( keys_list.get( 0 ), built.get( 0 ) );
    }
View Full Code Here

/**
*
*/
public class TCollectionsTest extends TestCase {
  public void testUnmodifiableList() {
    final TIntArrayList one = new TIntArrayList( new int[]{ 1, 2, 3, 4 } );
    final TIntArrayList two = new TIntArrayList( new int[]{ 1, 2, 3, 4 } );
    TIntList uOne = TCollections.unmodifiableList( one );
    TIntList uTwo = TCollections.unmodifiableList( two );

    assertEquals( one, two );
    assertEquals( uOne, uTwo );
View Full Code Here

    }

    public void clean() {
        TIntObjectMap<Sorter> oldSorters = sorters;
        TIntList oldSorterKeys = sorterKeys;
        sorterKeys = new TIntArrayList();
        sorters = new TIntObjectHashMap<Sorter>();
        reverseIndexer = new TIntObjectHashMap<TIntSet>();

        TIntIterator iter = oldSorterKeys.iterator();
        while (iter.hasNext()) {
View Full Code Here

            result[i++] = 0;
        }
    }

    public static int[] sparsify(int sparseFactor, float[] distr) {
        TIntArrayList resultList = new TIntArrayList();

        int cursor = 0;
        for (float ftmp : distr) {
            int itmp = Math.round(ftmp * sparseFactor);
            if (itmp != 0) {
                resultList.add(cursor);
                resultList.add(itmp);
            }
            cursor++;
        }

        return resultList.toArray();
    }
View Full Code Here

    public void _accumulate(int vecid, int[] pairs) {
        validateParams(vecid, pairs);
        if (!indexer.containsKey(vecid)) {
            _add(vecid, pairs);
        } else {
            TIntList indexes = new TIntArrayList();
            TIntFloatMap results = new TIntFloatHashMap();

            float max = Float.NEGATIVE_INFINITY;
            int cursor = indexer.get(vecid);
            int length = lengths.get(vecid);
            while (length > 0) {
                int pos = (int) data.get(cursor++);
                float val = data.get(cursor++);
                results.put(pos, val);
                if (val > max) {
                    max = val;
                }
                indexes.add(pos);
                length -= 2;
            }

            cursor = 0;
            while (cursor < pairs.length) {
                int pos = pairs[cursor++];
                float val = (float) pairs[cursor++];
                if (results.containsKey(pos)) {
                    val = results.get(pos) + val;
                    results.put(pos, val);
                    if (val > max) {
                        max = val;
                    }
                } else {
                    results.put(pos, val);
                    indexes.add(pos);
                }
            }
            indexes.sort();

            int start = data.size();
            indexer.put(vecid, start);
            lengths.put(vecid, indexes.size() * 2);
            TIntIterator iter = indexes.iterator();
            if (max < accumuFactor * sparseFactor) {
                while (iter.hasNext()) {
                    int key = iter.next();
                    float value = results.get(key);
                    data.add(key);
View Full Code Here

      set = FingerPrint.featureset(docs.get(i),type);

      featureLen[i]=set.size();
      Object[] sa =  set.toArray();     
      for(int j = 0; j < sa.length; j++) {
        TIntArrayList al = locationMap.get((String)sa[j]);
        if(al == null) {
          al = new TIntArrayList();
          al.add(i);
          locationMap.put((String)sa[j], al);
        }
        else
          al.add(i);
      }
    }
  }
View Full Code Here

TOP

Related Classes of gnu.trove.list.array.TIntArrayList

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.