Package kilim

Examples of kilim.RingQueue


import kilim.RingQueue;

public class TestRing extends TestCase {
    public void testInfiniteQueue() {
        Integer[] a = mkRandom();
        RingQueue<Integer> rq = new RingQueue(10);
        for (int i = 0; i < a.length; i++) {
            assertTrue("put returned false", rq.put(a[i]));
        }
        assertEquals("Queue size", a.length, rq.size());
        for (int i = 0; i < a.length; i++) {
            assertEquals("get[" + i + " ]returned different element", a[i], rq.get());
        }
        // No more elements. The next ha    d better be null
        assertNull("Queue should not have any more elements", rq.get());
        assertTrue(rq.size() == 0);
    }
View Full Code Here


        assertTrue(rq.size() == 0);
    }

    public void testBoundedQueue() {
        Integer[] a = mkRandom();
        RingQueue<Integer>   rq = new RingQueue(10, a.length);
        for (int i = 0; i < a.length; i++) {
            assertTrue("put returned false", rq.put(a[i]));
        }
        assertFalse("put should not accept more than bound", rq.put(100));
        assertTrue(rq.size() == a.length);
        for (int i = 0; i < a.length; i++) {
            assertEquals("get[" + i + " ]returned different element", a[i], rq.get());
        }
        // No more elements. The next had better be null
        assertNull("Queue should not have any more elements", rq.get());
        assertTrue(rq.size() == 0);
    }
View Full Code Here

TOP

Related Classes of kilim.RingQueue

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.