Package java.util

Examples of java.util.TreeSet.comparator()


        populate(orig);
        assertListsEqual(new ArrayList(orig), (List) _mgr.copyCollection(orig));

        TreeSet torig = (TreeSet) _mgr.newCollectionProxy(TreeSet.class, null,
            new CustomComparator());
        assertTrue(torig.comparator() instanceof CustomComparator);
        populate(torig);
        assertSortedSetsEqual(new TreeSet(torig), (SortedSet)
            _mgr.copyCollection(torig));
    }
View Full Code Here


        List orig = (List) _mgr.newCollectionProxy(ArrayList.class, null, null, true);
        populate(orig);
        assertListsEqual(new ArrayList(orig), (List) _mgr.copyCollection(orig));

        TreeSet torig = (TreeSet) _mgr.newCollectionProxy(TreeSet.class, null, new CustomComparator(), true);
        assertTrue(torig.comparator() instanceof CustomComparator);
        populate(torig);
        assertSortedSetsEqual(new TreeSet(torig), (SortedSet) _mgr.copyCollection(torig));
    }

    public void testCloneProxyCollection() {
View Full Code Here

    public void testCloneProxyCollection() {
        // List doesn't support clone()

        TreeSet torig = (TreeSet) _mgr.newCollectionProxy(TreeSet.class, null, new CustomComparator(), true);
        assertTrue(torig.comparator() instanceof CustomComparator);
        populate(torig);
        assertSortedSetsEquals(new TreeSet(torig), (SortedSet) torig.clone());
    }

    public void testListMethodsProxied() throws Exception {
View Full Code Here

  }

  static public class TreeSetSerializer extends CollectionSerializer {
    public void write (Kryo kryo, Output output, Collection collection) {
      TreeSet treeSet = (TreeSet)collection;
      kryo.writeClassAndObject(output, treeSet.comparator());
      super.write(kryo, output, collection);
    }

    protected TreeSet create (Kryo kryo, Input input, Class<Collection> type) {
      return new TreeSet((Comparator)kryo.readClassAndObject(input));
View Full Code Here

                "  <string>bye</string>\n" +
                "  <string>hi</string>\n" +
                "</sorted-set>";

        TreeSet result = (TreeSet) assertBothWays(set, expected);
        assertEquals(MyComparator.class, result.comparator().getClass());
    }

    public void testTreeSetWithoutComparator() {
        TreeSet set = new TreeSet();
        set.add("hi");
View Full Code Here

                "  <string>bye</string>\n" +
                "  <string>hi</string>\n" +
                "</sorted-set>";

        TreeSet result = (TreeSet)assertBothWays(set, expected);
        assertNull(result.comparator());
    }

    public void testEmptyTreeSet() {
        TreeSet set = new TreeSet();
View Full Code Here

    public void testEmptyTreeSet() {
        TreeSet set = new TreeSet();

        String expected = "<sorted-set/>";
        TreeSet result = (TreeSet)assertBothWays(set, expected);
        assertNull(result.comparator());
    }

    public void testTreeSetDoesNotUseComparatorAtDeserialization() {
        TreeSet set = new TreeSet(new UnusedComparator());
        set.add("guy");
View Full Code Here

                "  <string>hi</string>\n" +
                "</sorted-set>";

        assertEquals(expected, xstream.toXML(set));
        TreeSet result = (TreeSet) xstream.fromXML(expected);
        assertSame(UnusedComparator.THROWING_COMPARATOR, result.comparator());
        assertEquals(new ArrayList(set), new ArrayList(result));
    }
}
View Full Code Here

        List orig = (List) _mgr.newCollectionProxy(ArrayList.class, null, null, true);
        populate(orig);
        assertListsEqual(new ArrayList(orig), (List) _mgr.copyCollection(orig));

        TreeSet torig = (TreeSet) _mgr.newCollectionProxy(TreeSet.class, null, new CustomComparator(), true);
        assertTrue(torig.comparator() instanceof CustomComparator);
        populate(torig);
        assertSortedSetsEqual(new TreeSet(torig), (SortedSet) _mgr.copyCollection(torig));
    }

    public void testCloneProxyCollection() {
View Full Code Here

    public void testCloneProxyCollection() {
        // List doesn't support clone()

        TreeSet torig = (TreeSet) _mgr.newCollectionProxy(TreeSet.class, null, new CustomComparator(), true);
        assertTrue(torig.comparator() instanceof CustomComparator);
        populate(torig);
        assertSortedSetsEquals(new TreeSet(torig), (SortedSet) torig.clone());
    }

    public void testListMethodsProxied() throws Exception {
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.