Package thread.caches

Examples of thread.caches.KeyObject


    @Test
    public void testOrder() {
        Queue<CountKey<KeyObject>> queue = new PriorityQueue<CountKey<KeyObject>>(10);
        List<CountKey<KeyObject>> keys = new ArrayList<CountKey<KeyObject>>();
        for (int i = 0; i < 10; i++) {
            CountKey<KeyObject> k = new CountKey<KeyObject>(new KeyObject(i + ""));
            if (i == 7) {
                k.incrementCount();
                k.incrementCount();
                k.incrementCount();
            }
            keys.add(k);
            queue.offer(k);
        }
//        for (int i = 0; i < 10; i++) {
//            System.out.println(queue.peek());
//        }

        keys.get(5).incrementCount();
        keys.get(6).incrementCount();
        keys.get(5).incrementCount();
        queue = new PriorityQueue<>(keys);
        queue.poll();
        queue.offer(new CountKey<>(new KeyObject(87 + "")));
        for (int i = 0; i < 10; i++) {
            System.out.println(queue.poll());
        }
    }
View Full Code Here

TOP

Related Classes of thread.caches.KeyObject

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.