Package org.apache.commons.collections4.comparators

Examples of org.apache.commons.collections4.comparators.ReverseComparator


        assertNotSame(map1.hashCode(), map2.hashCode());
    }

    @SuppressWarnings({ "unchecked", "rawtypes" })
    public void testListValuedMapEqualsHashCodeContract() {
        ListValuedMap map1 = MultiValuedHashMap.listValuedHashMap();
        ListValuedMap map2 = MultiValuedHashMap.listValuedHashMap();

        map1.put("a", "a1");
        map1.put("a", "a2");
        map2.put("a", "a1");
        map2.put("a", "a2");
        assertEquals(map1, map2);
        assertEquals(map1.hashCode(), map2.hashCode());

        map1.put("b", "b1");
        map1.put("b", "b2");
        map2.put("b", "b2");
        map2.put("b", "b1");
        assertNotSame(map1, map2);
        assertNotSame(map1.hashCode(), map2.hashCode());
    }
View Full Code Here


        }
    }

    @SuppressWarnings({ "unchecked", "rawtypes" })
    public void testEqualsHashCodeContract() {
        MultiValuedMap map1 = new MultiValuedLinkedHashMap();
        MultiValuedMap map2 = new MultiValuedLinkedHashMap();

        map1.put("a", "a1");
        map1.put("a", "a2");
        map2.put("a", "a2");
        map2.put("a", "a1");
        assertEquals(map1, map2);
        assertEquals(map1.hashCode(), map2.hashCode());

        map2.put("a", "a2");
        assertNotSame(map1, map2);
        assertNotSame(map1.hashCode(), map2.hashCode());
    }
View Full Code Here

        assertEquals(2, listMap.get("B").size());
    }

    @SuppressWarnings({ "unchecked", "rawtypes" })
    public void testEqualsHashCodeContract() {
        MultiValuedMap map1 = new MultiValuedHashMap();
        MultiValuedMap map2 = new MultiValuedHashMap();

        map1.put("a", "a1");
        map1.put("a", "a2");
        map2.put("a", "a2");
        map2.put("a", "a1");
        assertEquals(map1, map2);
        assertEquals(map1.hashCode(), map2.hashCode());

        map2.put("a", "a2");
        assertNotSame(map1, map2);
        assertNotSame(map1.hashCode(), map2.hashCode());
    }
View Full Code Here

        assertNotSame(map1.hashCode(), map2.hashCode());
    }

    @SuppressWarnings({ "unchecked", "rawtypes" })
    public void testSetValuedMapEqualsHashCodeContract() {
        SetValuedMap map1 = MultiValuedLinkedHashMap.setValuedLinkedHashMap();
        SetValuedMap map2 = MultiValuedLinkedHashMap.setValuedLinkedHashMap();

        map1.put("a", "a1");
        map1.put("a", "a2");
        map2.put("a", "a2");
        map2.put("a", "a1");
        assertEquals(map1, map2);
        assertEquals(map1.hashCode(), map2.hashCode());

        map2.put("a", "a2");
        assertEquals(map1, map2);
        assertEquals(map1.hashCode(), map2.hashCode());

        map2.put("a", "a3");
        assertNotSame(map1, map2);
        assertNotSame(map1.hashCode(), map2.hashCode());
    }
View Full Code Here

        assertNotSame(map1.hashCode(), map2.hashCode());
    }

    @SuppressWarnings({ "unchecked", "rawtypes" })
    public void testSetValuedMapEqualsHashCodeContract() {
        SetValuedMap map1 = MultiValuedHashMap.setValuedHashMap();
        SetValuedMap map2 = MultiValuedHashMap.setValuedHashMap();

        map1.put("a", "a1");
        map1.put("a", "a2");
        map2.put("a", "a2");
        map2.put("a", "a1");
        assertEquals(map1, map2);
        assertEquals(map1.hashCode(), map2.hashCode());

        map2.put("a", "a2");
        assertEquals(map1, map2);
        assertEquals(map1.hashCode(), map2.hashCode());

        map2.put("a", "a3");
        assertNotSame(map1, map2);
        assertNotSame(map1.hashCode(), map2.hashCode());
    }
View Full Code Here

  }

  //loads the files and removes words which occur less than 5 tims
  public void loadProgram() throws FileNotFoundException
  {
    Bag wordBag = new HashBag();

    //Load all the medical files in the directory
    File[] fileList = new File(recordsDir).listFiles();
    for (int i = 0; i<fileList.length; i++) {
      loadFile(fileList[i].toString(), wordBag);
    }

    //dump bag into frequent who appear in 5 or more medical records
    for (Object obj : wordBag.uniqueSet()) {
      if (wordBag.getCount(obj) > 4){
        frequent.add((String)obj);
      }
    }

  }
View Full Code Here



    //put entries in bag to get count
    String entryBuilder;
    Bag <String> bagOfEntries = new <String>HashBag();
    for (ArrayList<String> temp : output)
    {
      entryBuilder = "";
      for (String tempWord : temp)
      {
        String scrap = tempWord + " ";
        entryBuilder += scrap;
      }
      bagOfEntries.add(entryBuilder);
    }

    //make a map with values - count and keys - string and sort by frequency
    Map<String, Integer> frequentWords = new <String, Integer>HashMap();
    for (String pattern : bagOfEntries.uniqueSet()) {
      frequentWords.put(pattern, bagOfEntries.getCount(pattern));
    }
    Map.Entry<String, Integer>[] entries = frequentWords.entrySet().toArray(new Map.Entry[0]);
    Arrays.sort(entries, new Comparator<Map.Entry<String, Integer>>() {
        public int compare(Map.Entry<String, Integer> o1, Map.Entry<String, Integer> o2) {
          return o2.getValue().compareTo(o1.getValue());
View Full Code Here

    // collections testing framework
    // ------------------------------------------------------------------------

    @Override
    public Comparator<Boolean> makeObject() {
        return new BooleanComparator();
    }
View Full Code Here

    // tests
    // ------------------------------------------------------------------------

    @Test
    public void testConstructors() {
        allTests(false,new BooleanComparator());
        allTests(false,new BooleanComparator(false));
        allTests(true,new BooleanComparator(true));
    }
View Full Code Here

        allTests(true,BooleanComparator.booleanComparator(true));
    }

    @Test
    public void testEqualsCompatibleInstance() {
        assertEquals(new BooleanComparator(),new BooleanComparator(false));
        assertEquals(new BooleanComparator(false),new BooleanComparator(false));
        assertEquals(new BooleanComparator(false),BooleanComparator.getFalseFirstComparator());
        assertSame(BooleanComparator.getFalseFirstComparator(),BooleanComparator.booleanComparator(false));

        assertEquals(new BooleanComparator(true),new BooleanComparator(true));
        assertEquals(new BooleanComparator(true),BooleanComparator.getTrueFirstComparator());
        assertSame(BooleanComparator.getTrueFirstComparator(),BooleanComparator.booleanComparator(true));

        assertTrue(!new BooleanComparator().equals(new BooleanComparator(true)));
        assertTrue(!new BooleanComparator(true).equals(new BooleanComparator(false)));
    }
View Full Code Here

TOP

Related Classes of org.apache.commons.collections4.comparators.ReverseComparator

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.