Package org.neo4j.kernel.impl.util

Examples of org.neo4j.kernel.impl.util.ArrayIntSet$ArrayIntIterator


public class TestArrayIntSet
{
    @Test
    public void testArrayIntSet()
    {
        ArrayIntSet set = new ArrayIntSet();

        set.add( 1 );
        set.add( 2 );
        set.add( 3 );
        set.add( 4 );
        set.add( 5 );
        set.add( 6 );
        set.add( 7 );
        set.add( 8 );
        set.add( 9 );
        set.add( 10 );

        int count = 0;
        for ( int value : set.values() )
        {
            assertTrue( set.contains( value ) );
            count++;
        }
        assertEquals( 10, count );

        assertTrue( set.remove( 2 ) );
        assertTrue( set.remove( 9 ) );
        assertTrue( set.remove( 5 ) );
        assertTrue( !set.remove( 2 ) );
        assertTrue( !set.remove( 9 ) );
        assertTrue( !set.remove( 5 ) );

        count = 0;
        for ( int value : set.values() )
        {
            assertTrue( set.contains( value ) );
            count++;
        }
        assertEquals( 7, count );

        assertTrue( set.remove( 3 ) );
        assertTrue( set.remove( 8 ) );
        assertTrue( set.remove( 4 ) );
        assertTrue( !set.remove( 3 ) );
        assertTrue( !set.remove( 8 ) );
        assertTrue( !set.remove( 4 ) );

        count = 0;
        for ( int value : set.values() )
        {
            assertTrue( set.contains( value ) );
            count++;
        }
        assertEquals( 4, count );

        assertTrue( set.remove( 1 ) );
        assertTrue( set.remove( 7 ) );
        assertTrue( set.remove( 6 ) );
        assertTrue( !set.remove( 1 ) );
        assertTrue( !set.remove( 7 ) );
        assertTrue( !set.remove( 6 ) );

        count = 0;
        for ( int value : set.values() )
        {
            assertTrue( set.contains( value ) );
            count++;
        }
        assertEquals( 1, count );

        assertTrue( set.remove( 10 ) );
        assertTrue( !set.remove( 10 ) );

        count = 0;
        for ( int value : set.values() )
        {
            assertTrue( set.contains( value ) );
            count++;
        }
        assertEquals( 0, count );
    }
View Full Code Here


    }
   
    @Test
    public void testContains()
    {
        ArrayIntSet set = new ArrayIntSet();
        for ( int i = 0; i < 10; i++ )
        {
            set.add( i );
            assertTrue( set.contains( i ) );
        }
        for ( int i = 0; i < 10; i++ )
        {
            assertTrue( set.contains( i ) );
        }
        for ( int i = 0; i < 10; i+=2 )
        {
            set.remove( i );
            assertTrue( !set.contains( i ) );
        }
        for ( int i = 0; i < 10; i++ )
        {
            if ( i % 2 == 0 )
            {
                assertTrue( !set.contains( i ) );
            }
            else
            {
                assertTrue( set.contains( i ) );
            }
        }
       
        for ( int i = 0; i < 1000; i++ )
        {
            set.add( i );
            assertTrue( set.contains( i ) );
        }
        for ( int i = 0; i < 1000; i++ )
        {
            assertTrue( set.contains( i ) );
        }
        for ( int i = 0; i < 1000; i+=2 )
        {
            set.remove( i );
            assertTrue( !set.contains( i ) );
        }
        for ( int i = 0; i < 1000; i++ )
        {
            if ( i % 2 == 0 )
            {
                assertTrue( !set.contains( i ) );
            }
            else
            {
                assertTrue( set.contains( i ) );
            }
        }
    }
View Full Code Here

TOP

Related Classes of org.neo4j.kernel.impl.util.ArrayIntSet$ArrayIntIterator

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.