Package java.util

Examples of java.util.Comparator.compare()


    SearchHit h1 = new SearchHit(null, "", "", "", "", new Date(123), 0.5F);
    SearchHit h2 = new SearchHit(null, "", "", "", "", new Date(321), 0.3F);

    assertTrue(comp.compare(h1, h1) == 0);
    assertTrue(comp.compare(h1, h2) != 0);
    assertTrue(comp.compare(h1, h2) < 0);
    assertTrue(comp.compare(h2, h1) > 0);
  }

}
View Full Code Here


    SearchHit h2 = new SearchHit(null, "", "", "", "", new Date(321), 0.3F);

    assertTrue(comp.compare(h1, h1) == 0);
    assertTrue(comp.compare(h1, h2) != 0);
    assertTrue(comp.compare(h1, h2) < 0);
    assertTrue(comp.compare(h2, h1) > 0);
  }

}
View Full Code Here

          return _compare(value1.toString(), value2.toString());
        }
      }
      else
      {
        return comparator.compare(value1, value2);
      }
    }

    private int _compare(
      String s1,
View Full Code Here

        currentValue = getText(current, null);
      else
        currentValue = getValue(current, null);
      if (value == null)
        value = currentValue;
      else if (0 != comparatorToUse.compare(currentValue, value)) {
        value = null;
        break;
      }
    }
    if (value == null && useMultipleValue) {
View Full Code Here

        // iterate over all comparators in the chain
        Iterator comparators = comparatorChain.iterator();
        for (int comparatorIndex = 0; comparators.hasNext(); ++comparatorIndex) {

            Comparator comparator = (Comparator) comparators.next();
            int retval = comparator.compare(o1,o2);
            if (retval != 0) {
                // invert the order if it is a reverse sort
                if (orderingBits.get(comparatorIndex) == true) {
                    retval *= -1;
                }
View Full Code Here

        // =====================================================================
        //   Test Expectations
        // =====================================================================
        Comparator comparator = createComparator();
        int result = comparator.compare(normalPriorityHighSpecificityMock,
                                        normalPriorityLowSpecificityMock);
        assertEquals("Comparator result", GREATER_THAN, result);
    }

    /**
 
View Full Code Here

        // =====================================================================
        //   Test Expectations
        // =====================================================================
        Comparator comparator = createComparator();
        int result = comparator.compare(importantPriorityLowSpecificityMock,
                normalPriorityLowSpecificityMock);
        assertEquals("Comparator result", expectedResult, result);
    }

    /**
 
View Full Code Here

    Object o1 = filteredModel.getValueAt(row1, column);
    Object o2 = filteredModel.getValueAt(row2, column);

    Comparator comparator = columnComparators[column];
    if (comparator != null) {
      return comparator.compare(o1, o2);
    }

    return COMPARABLE_COMPARATOR.compare(o1, o2);
  }
View Full Code Here

        Object[] tree = heap.elements;
        for (int i = 1; i <= heap.size; i++) {
            Object parent = tree[i];
            if (i * 2 <= heap.size) {
                assertTrue("Parent is less than or equal to its left child", c.compare(parent, tree[i * 2]) <= 0);
            }
            if (i * 2 + 1 < heap.size) {
                assertTrue("Parent is less than or equal to its right child", c.compare(parent, tree[i * 2 + 1]) <= 0);
            }
        }
View Full Code Here

            Object parent = tree[i];
            if (i * 2 <= heap.size) {
                assertTrue("Parent is less than or equal to its left child", c.compare(parent, tree[i * 2]) <= 0);
            }
            if (i * 2 + 1 < heap.size) {
                assertTrue("Parent is less than or equal to its right child", c.compare(parent, tree[i * 2 + 1]) <= 0);
            }
        }
    }

    //----------------------------------------------------------------------- 
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.