当前位置: 首页>>代码示例>>Java>>正文


Java TIntList类代码示例

本文整理汇总了Java中gnu.trove.list.TIntList的典型用法代码示例。如果您正苦于以下问题:Java TIntList类的具体用法?Java TIntList怎么用?Java TIntList使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


TIntList类属于gnu.trove.list包,在下文中一共展示了TIntList类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: subList

import gnu.trove.list.TIntList; //导入依赖的package包/类
/** {@inheritDoc} */
  public TIntList subList( int begin, int end ) {
  	if ( end < begin ) {
	throw new IllegalArgumentException( "end index " + end +
		" greater than begin index " + begin );
}
if ( begin < 0 ) {
	throw new IndexOutOfBoundsException( "begin index can not be < 0" );
}
if ( end > _data.length ) {
	throw new IndexOutOfBoundsException( "end index < " + _data.length );
}
      TIntArrayList list = new TIntArrayList( end - begin );
      for ( int i = begin; i < end; i++ ) {
      	list.add( _data[ i ] );
      }
      return list;
  }
 
开发者ID:JianpingZeng,项目名称:xcc,代码行数:19,代码来源:TIntArrayList.java

示例2: subList

import gnu.trove.list.TIntList; //导入依赖的package包/类
/** {@inheritDoc} */
public TIntList subList(int begin, int end) {
    if (end < begin) {
        throw new IllegalArgumentException("begin index " + begin +
                " greater than end index " + end);
    }
    if (size < begin) {
        throw new IllegalArgumentException("begin index " + begin +
                " greater than last index " + size);
    }
    if (begin < 0) {
        throw new IndexOutOfBoundsException("begin index can not be < 0");
    }
    if (end > size) {
        throw new IndexOutOfBoundsException("end index < " + size);
    }

    TIntLinkedList ret = new TIntLinkedList();
    TIntLink tmp = getLinkAt(begin);
    for (int i = begin; i < end; i++) {
        ret.add(tmp.getValue()); // copy
        tmp = tmp.getNext();
    }

    return ret;
}
 
开发者ID:JianpingZeng,项目名称:xcc,代码行数:27,代码来源:TIntLinkedList.java

示例3: equals

import gnu.trove.list.TIntList; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public boolean equals( Object other ) {
    if ( other == this ) {
        return true;
    }
    if ( !( other instanceof TIntList ) ) return false;

    TIntList that = ( TIntList )other;
    if ( size() != that.size() ) return false;

    for( int i = 0; i < size(); i++ ) {
        if ( get( i ) != that.get( i ) ) {
            return false;
        }
    }
    return true;
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:19,代码来源:TIntLinkedList.java

示例4: testSortPartial

import gnu.trove.list.TIntList; //导入依赖的package包/类
public void testSortPartial() {
    int element_count = 20;
    TIntList a = new TIntArrayList();
    for ( int i = 1; i <= element_count; i++ ) {
        a.add( i );
    }

    a.reverse();
    a.sort( 5, 15 );

    int[] expected = {20, 19, 18, 17, 16, 6, 7, 8, 9, 10,
                      11, 12, 13, 14, 15, 5, 4, 3, 2, 1};
    for ( int i = 0; i < a.size(); i++ ) {
        assertEquals( expected[i], a.get( i ) );
    }

    try {
        a.sort( 20, 10 );
        fail( "Expected IllegalArgumentException" );
    }
    catch ( IllegalArgumentException ex ) {
        // Expected
    }
}
 
开发者ID:leventov,项目名称:trove-over-koloboke-compile,代码行数:25,代码来源:TPrimitiveArrayListTest.java

示例5: read

import gnu.trove.list.TIntList; //导入依赖的package包/类
@Override
public void read(ByteBuf buf) throws Exception {
    int records = buf.readUnsignedShort();
    TIntList list = new TIntArrayList();
    for (int i = 0; i < records && i < 4096; i++) {
        if (buf.readBoolean()) {
            list.add(Packet.readInt24(buf));
        } else {
            int start = Packet.readInt24(buf);
            int end = Packet.readInt24(buf);
            if ((end - start) > 512) {
                end = start + 512;
            }
            for (int cursor = start; cursor <= end; ++cursor) {
                list.add(cursor);
            }
        }
    }
    this.packets = list.toArray();
}
 
开发者ID:PocketServer,项目名称:PocketServer,代码行数:21,代码来源:AbstractRaknetAck.java

示例6: testContains

import gnu.trove.list.TIntList; //导入依赖的package包/类
public void testContains() {
    int element_count = 10;

    TIntList a = new TIntArrayList();
    assertTrue( a.isEmpty() );

    for ( int i = 1; i <= element_count; i++ ) {
        a.add( i );
    }

    for ( int i = 1; i <= element_count; i++ ) {
        assertTrue( "element " + i + " not found in " + a, a.contains( i ) );
    }

    assertFalse( "list doesn't hold MAX_VALUE: " + a,
            a.contains( Integer.MAX_VALUE ) );
}
 
开发者ID:leventov,项目名称:trove-over-koloboke-compile,代码行数:18,代码来源:TPrimitiveArrayListTest.java

示例7: testIteratorAbuseNext

import gnu.trove.list.TIntList; //导入依赖的package包/类
public void testIteratorAbuseNext() {
    int element_count = 20;
    TIntList list = new TIntLinkedList();
    for ( int i = 0; i < element_count; i++ ) {
        list.add( i );
    }

    TIntIterator iter = list.iterator();
    while ( iter.hasNext() ) {
        iter.next();
    }
    assertFalse( iter.hasNext() );

    list.remove( 5, 10 );
    assertFalse( iter.hasNext() );
    try {
        iter.next();
        fail( "Expected NoSuchElementException" );
    } catch( NoSuchElementException ex ) {
        // Expected.
    }
}
 
开发者ID:leventov,项目名称:trove-over-koloboke-compile,代码行数:23,代码来源:TPrimitiveLinkedListTest.java

示例8: testSum

import gnu.trove.list.TIntList; //导入依赖的package包/类
public void testSum() {
    TIntList list = new TIntArrayList();
    assertEquals(0, list.sum());

    list.add(1);
    assertEquals(1, list.sum());

    list.add(1234);
    assertEquals(1235, list.sum());

    list.removeAt(0);
    assertEquals(1234, list.sum());

    list.clear();
    assertEquals(0, list.sum());
}
 
开发者ID:palantir,项目名称:trove-3.0.3,代码行数:17,代码来源:TArrayListTest.java

示例9: testIterator

import gnu.trove.list.TIntList; //导入依赖的package包/类
public void testIterator() {
    int element_count = 20;
    TIntList list = new TIntOffheapArrayList();
    for ( int i = 0; i < element_count; i++ ) {
        list.add( i );
    }

    TIntIterator iter = list.iterator();
    assertTrue( "iter should have next: " + list.size(), iter.hasNext() );

    int j = 0;
    while ( iter.hasNext() ) {
        int next = iter.next();
        assertEquals( j, next );
        j++;
    }
    assertFalse( iter.hasNext() );
}
 
开发者ID:palantir,项目名称:trove-3.0.3,代码行数:19,代码来源:TPrimitiveOffheapArrayListTest.java

示例10: testReversePartial

import gnu.trove.list.TIntList; //导入依赖的package包/类
public void testReversePartial() {
    int element_count = 20;
    TIntList a = new TIntArrayList();
    for ( int i = 1; i <= element_count; i++ ) {
        a.add( i );
    }

    a.reverse( 1, 19 );

    int[] expected = {1, 19, 18, 17, 16, 15, 14, 13, 12, 11,
                      10, 9, 8, 7, 6, 5, 4, 3, 2, 20};
    for ( int i = 0; i < a.size(); i++ ) {
        assertEquals( expected[i], a.get( i ) );
    }

    try {
        a.reverse( 20, 10 );
        fail( "Expected IllegalArgumentException" );
    }
    catch ( IllegalArgumentException ex ) {
        // Expected
    }
}
 
开发者ID:leventov,项目名称:trove-over-koloboke-compile,代码行数:24,代码来源:TPrimitiveArrayListTest.java

示例11: testGrep

import gnu.trove.list.TIntList; //导入依赖的package包/类
public void testGrep() {
    int element_count = 20;
    TIntList a = new TIntOffheapArrayList();
    for ( int i = 1; i < element_count; i++ ) {
        a.add( i );
    }

    TIntList grepped = a.grep( new TIntProcedure() {
        @Override
        public boolean execute( int value ) {
            return value > 10;
        }
    } );

    for ( int i = 0; i < grepped.size(); i++ ) {
        int expected = i + 11;
        assertEquals( expected, grepped.get( i ) );
    }
}
 
开发者ID:palantir,项目名称:trove-3.0.3,代码行数:20,代码来源:TPrimitiveOffheapArrayListTest.java

示例12: testInverseGrep

import gnu.trove.list.TIntList; //导入依赖的package包/类
public void testInverseGrep() {
    int element_count = 20;
    TIntList a = new TIntOffheapArrayList();
    for ( int i = 1; i < element_count; i++ ) {
        a.add( i );
    }

    TIntList grepped = a.inverseGrep( new TIntProcedure() {
        @Override
        public boolean execute( int value ) {
            return value <= 10;
        }
    } );

    for ( int i = 0; i < grepped.size(); i++ ) {
        int expected = i + 11;
        assertEquals( expected, grepped.get( i ) );
    }
}
 
开发者ID:palantir,项目名称:trove-3.0.3,代码行数:20,代码来源:TPrimitiveOffheapArrayListTest.java

示例13: testForEachDescending

import gnu.trove.list.TIntList; //导入依赖的package包/类
public void testForEachDescending() {
    int element_count = 20;
    TIntList a = new TIntOffheapArrayList();
    for ( int i = 1; i < element_count; i++ ) {
        a.add( i );
    }

    class ForEach implements TIntProcedure {
        TIntList built = new TIntOffheapArrayList();


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

    ForEach foreach = new ForEach();
    a.forEachDescending( foreach );
}
 
开发者ID:palantir,项目名称:trove-3.0.3,代码行数:22,代码来源:TPrimitiveOffheapArrayListTest.java

示例14: testInsertAtEnd

import gnu.trove.list.TIntList; //导入依赖的package包/类
public void testInsertAtEnd() {
    int element_count = 10;

    TIntList a = new TIntArrayList();
    assertTrue( a.isEmpty() );

    for ( int i = 1; i <= element_count; i++ ) {
        a.add( i );
    }

    a.insert( a.size(), 11 );

    for ( int i = 0; i < element_count; i++ ) {
        assertEquals( i + 1, a.get( i ) );
    }
    for ( int i = element_count;
          i < a.size();
          i++ ) {
        int expected = i + 1;
        assertEquals( expected, a.get( i ) );
    }
}
 
开发者ID:palantir,项目名称:trove-3.0.3,代码行数:23,代码来源:TPrimitiveArrayListTest.java

示例15: testRemoveMultiple

import gnu.trove.list.TIntList; //导入依赖的package包/类
public void testRemoveMultiple() {
    int element_count = 20;

    TIntList a = new TIntArrayList();
    assertTrue( a.isEmpty() );

    for ( int i = 1; i <= element_count; i++ ) {
        a.add( i );
    }

    // Remove odd offsets, which are even numbers.
    for ( int i = element_count; i >= 0; i-- ) {
        if ( i % 2 == 1 ) {
            a.removeAt( i );
        }
    }

    for ( int i = 0; i < a.size(); i++ ) {
        int expected = i * 2 + 1;
        assertTrue( "index " + i + " expected " + expected, a.get( i ) == expected );
    }
}
 
开发者ID:palantir,项目名称:trove-3.0.3,代码行数:23,代码来源:TPrimitiveArrayListTest.java


注:本文中的gnu.trove.list.TIntList类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。