Package gnu.trove.list.array

Examples of gnu.trove.list.array.TIntArrayList


        Thread.sleep(10);
        continue;
      }
      Entry<String, TIntArrayList> entry = iterator.next();

      TIntArrayList al = entry.getValue();
      CalcSimilarity cs = new CalcSimilarity(al);
      pool.execute(cs);
    }
    while(pool.getActiveCount()>0){
      Thread.sleep(10);
View Full Code Here


    while ((line = in.readLine()) != null) {
      line = line.trim()
      if(line.length()==0)
        continue;
      String[] toks = line.split("\\s+");
      TIntArrayList wordlist = new TIntArrayList();
      for(int j=0;j<toks.length;j++){
        String tok = toks[j];
        if(sw.isStopWord(tok))
          continue;
        int idx = dict.lookupIndex(tok);
        wordlist.add(idx);
      }
      documentsList.add(wordlist);
    }
    in.close();
    int[][] documents;
View Full Code Here

  private static final long serialVersionUID = 3666569734894722449L;
  TIntArrayList data;

  public BinarySparseVector(){
    data = new TIntArrayList();
  }
View Full Code Here

  public BinarySparseVector(){
    data = new TIntArrayList();
  }

  public BinarySparseVector(int len) {
    data = new TIntArrayList(len);
  }
View Full Code Here

    ww= new float[]{ 1, 0, 0, 0, 0, 0, 0 };   
    e = MyArrays.entropy(ww);   
    System.out.print(e + " ");
   
    System.out.println();
    TIntArrayList www = new TIntArrayList();
    for(int i=0;i<100;i++){
    www.add(1);
    w = www.toArray();
    e = MyArrays.entropy(w);   
    System.out.print(e + " ");
    System.out.println(e/w.length);
    }
    System.out.println();
View Full Code Here

    ysize = la.size();
    factory.setStopIncrement(true);
  }

  public static int[] addFeature(IFeatureAlphabet fa, ArrayList<String> str,  int ysize) {
    TIntArrayList indices = new TIntArrayList();
    String constant = "////";
    str.add(constant);
    for(String s: str){
      int i = fa.lookupIndex(s,ysize);
      if(i!=-1)
        indices.add(i);
    }
    return indices.toArray();
  }
View Full Code Here

   * 由上到下存储路径
   */
  public void CalcPath() {
    treepath = new int[size][];
    for(int i=0;i<size;i++){
      TIntArrayList  list= new TIntArrayList ();
      list.add(i);
      Integer j=i;
      while((j=edgesInv.get(j))!=null){
        list.add(j);
      }
      int s = list.size();
      treepath[i] = new int[s];
      for(int k=0;k<s;k++){
        treepath[i][s-k-1] = list.get(k);
      }
    }   
  }
View Full Code Here

/**
*
*/
public class TDecoratorsTest extends TestCase {
  public void testIntListDecorator() {
    TIntList list = new TIntArrayList();
    list.add( 2 );
    list.add( 3 );
    list.add( 4 );
    list.add( 5 );
    list.add( 6 );

    List<Integer> wrapped_list = TDecorators.wrap( list );
    assertEquals( 5, wrapped_list.size() );
    assertEquals( Integer.valueOf( 2 ), wrapped_list.get( 0 ) );
    assertEquals( Integer.valueOf( 3 ), wrapped_list.get( 1 ) );
    assertEquals( Integer.valueOf( 4 ), wrapped_list.get( 2 ) );
    assertEquals( Integer.valueOf( 5 ), wrapped_list.get( 3 ) );
    assertEquals( Integer.valueOf( 6 ), wrapped_list.get( 4 ) );

    list.removeAt( 1 );

    assertEquals( 4, list.size() );
    assertEquals( Integer.valueOf( 2 ), wrapped_list.get( 0 ) );
    assertEquals( Integer.valueOf( 4 ), wrapped_list.get( 1 ) );
    assertEquals( Integer.valueOf( 5 ), wrapped_list.get( 2 ) );
    assertEquals( Integer.valueOf( 6 ), wrapped_list.get( 3 ) );

    wrapped_list.remove( 1 );

    assertEquals( 3, list.size() );
    assertEquals( 2, list.get( 0 ) );
    assertEquals( 5, list.get( 1 ) );
    assertEquals( 6, list.get( 2 ) );

    list.clear();
    assertTrue( wrapped_list.isEmpty() );

    wrapped_list.add( Integer.valueOf( 7 ) );
    assertEquals( 1, list.size() );
    assertEquals( 7, list.get( 0 ) );

    wrapped_list.clear();
    assertTrue( list.isEmpty() );

    list.add( 8 );
    list.add( 9 );
    list.add( 10 );

    Iterator<Integer> wrapper_list_it = wrapped_list.iterator();
    assertTrue( wrapper_list_it.hasNext() );
    assertEquals( Integer.valueOf( 8 ), wrapper_list_it.next() );
    assertTrue( wrapper_list_it.hasNext() );
    assertEquals( Integer.valueOf( 9 ), wrapper_list_it.next() );
    assertTrue( wrapper_list_it.hasNext() );
    assertEquals( Integer.valueOf( 10 ), wrapper_list_it.next() );
    assertFalse( wrapper_list_it.hasNext() );

    wrapper_list_it = wrapped_list.iterator();
    assertTrue( wrapper_list_it.hasNext() );
    assertEquals( Integer.valueOf( 8 ), wrapper_list_it.next() );
    wrapper_list_it.remove();
    assertTrue( wrapper_list_it.hasNext() );
    assertEquals( Integer.valueOf( 9 ), wrapper_list_it.next() );
    assertTrue( wrapper_list_it.hasNext() );
    assertEquals( Integer.valueOf( 10 ), wrapper_list_it.next() );
    assertFalse( wrapper_list_it.hasNext() );

    assertEquals( 2, list.size() );
    assertEquals( 9, list.get( 0 ) );
    assertEquals( 10, list.get( 1 ) );
  }
View Full Code Here

    assertEquals( 9, list.get( 0 ) );
    assertEquals( 10, list.get( 1 ) );
  }

  public void testIntListDecoratorSubList() {
    TIntList list = new TIntArrayList();
    list.add( 2 );
    list.add( 3 );
    list.add( 4 );
    list.add( 5 );
    list.add( 6 );

    List<Integer> wrapped_list = TDecorators.wrap( list );

    List<Integer> sublist = wrapped_list.subList( 1, 4 );
    assertEquals( 3, sublist.size() );
    assertEquals( Integer.valueOf( 3 ), sublist.get( 0 ) );
    assertEquals( Integer.valueOf( 4 ), sublist.get( 1 ) );
    assertEquals( Integer.valueOf( 5 ), sublist.get( 2 ) );

    sublist.clear();

    assertEquals( 2, list.size() );
    assertEquals( 2, list.get( 0 ) );
    assertEquals( 6, list.get( 1 ) );
  }
View Full Code Here

      stack.equals( stack ) );

        assertTrue( "stacks should be equal: " + stack + ", " + other,
      stack.equals( other ) );

        TIntArrayList list = new TIntArrayList( stack.toArray() );
        assertFalse( "stack should not equal list: " + stack + ", " + list,
      stack.equals( list ) );
    }
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.