Package com.carrotsearch.hppc

Examples of com.carrotsearch.hppc.IntArrayDeque


   
    st = System.currentTimeMillis();
   
    for (i=0; i<size; i++)
    {
      deque = new IntArrayDeque();
     
      for (j=0; j<len; j++)
        deque.addLast(j);
     
      deque.removeLast();
View Full Code Here


   
    @Test
    public void testWithProcedureClosure()
    {
        // [[[start:iteration-deques-using-procedures]]]
        final IntArrayDeque deque = prepare(10);

        // Deques also support iteration through [type]Procedure interfaces.
        // The apply() method will be called once for each element in the deque.
       
        // Iteration from head to tail
        deque.forEach(new IntProcedure()
        {
            public void apply(int value)
            {
                System.out.println(value);
            }
View Full Code Here

    @Test
    public void testDirectBufferLoop() throws Exception
    {
        // [[[start:iteration-deques-using-direct-buffer-access]]]
        final IntArrayDeque deque = prepare(10);
       
        // For the fastest iteration, you can access the deque's data buffer directly.
        // Note that this time it's a little more complicated than with array lists.
        final int [] buffer = deque.buffer;
        final int bufferSize = buffer.length;
       
        // Iteration from head to tail
        final int forwardStart = deque.head;
        final int forwardStop = forwardStart + deque.size();
        for (int i = forwardStart; i < forwardStop; i++)
        {
            System.out.println(buffer[i % bufferSize]);
        }
       
        // Iteration from tail to head
        final int backwardStart = deque.tail + bufferSize - 1;
        final int backwardStop = backwardStart - deque.size();
        for (int i = backwardStart; i > backwardStop; i--)
        {
            System.out.println(buffer[i % bufferSize]);
        }
        // [[[end:iteration-deques-using-direct-buffer-access]]]
View Full Code Here

public class IteratingOverDeques
{
    IntArrayDeque prepare(int size)
    {
        final IntArrayDeque deque = new IntArrayDeque(size);
        for (int i = 0; i < size; i++)
        {
            deque.addFirst(i);
        }
        return deque;
    }
View Full Code Here

    @Test
    public void testIterableCursor()
    {
        // [[[start:iteration-deques-using-iterator]]]
        // Prepare some deque to iterate over
        final IntArrayDeque deque = prepare(10);
       
        // Deques implement the Iterable interface that returns [type]Cursor elements.
        // The cursor contains the index and value of the current element.
       
        // Please note that the for-each loop as below will always
View Full Code Here

        IArcPredicate arcPredicate, boolean pruneOneNodeSubrgaphs)
    {
        // Find coherent sub-graphs using breadth-first search
        final boolean [] nodesChecked = new boolean [vertexCount];
        final List<IntArrayList> clusterGroups = Lists.newArrayList();
        final IntArrayDeque nodeQueue = new IntArrayDeque();

        for (int i = 0; i < vertexCount; i++)
        {
            if (!nodesChecked[i])
            {
                nodeQueue.clear();
                nodeQueue.addLast(i);
                nodesChecked[i] = true;
                IntArrayList clusterGroup = new IntArrayList();

                while (!nodeQueue.isEmpty())
                {
                    // Get a node from the queue
                    int node = nodeQueue.removeFirst();

                    // Add to the current sub-graph (cluster group)
                    clusterGroup.add(node);

                    // Add all its non-checked neighbors to the queue
                    for (int j = i + 1; j < vertexCount; j++)
                    {
                        if (!nodesChecked[j])
                        {
                            if (arcPredicate.isArcPresent(node, j))
                            {
                                nodeQueue.addLast(j);
                                nodesChecked[j] = true;
                            }
                        }
                    }
                }
View Full Code Here

   
    st = System.currentTimeMillis();
   
    for (i=0; i<size; i++)
    {
      deque = new IntArrayDeque();
     
      for (j=0; j<len; j++)
        deque.addLast(j);
     
      deque.removeLast();
View Full Code Here

   
    st = System.currentTimeMillis();
   
    for (i=0; i<size; i++)
    {
      deque = new IntArrayDeque();
     
      for (j=0; j<len; j++)
        deque.addLast(j);
     
      deque.removeLast();
View Full Code Here

TOP

Related Classes of com.carrotsearch.hppc.IntArrayDeque

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.