/**
   * sums up all elements of list, returns as int
   *
   * @param <T> The type of Summation elements
   * @param list A list of T
   * @return the sum
   */
  public static <T extends Number> int sum_int(final Collection<T> list) {
    int _sum = 0;

    for (T t : list) {
      _sum += t.intValue();
    }

    return _sum;
  }
Example #2
0
      @SuppressWarnings({"unchecked", "rawtypes"})
      public T next() {
        assert hasNext : "End of iterator reached.";

        T retVal = current;

        if (retVal instanceof Long) {
          long value = current.longValue();
          value += inc;
          current = (T) new Long(value);
        } else {
          int value = current.intValue();
          value += inc;
          current = (T) new Integer(value);
        }
        hasNext =
            inc == -1 && ((Comparable) end).compareTo(current) <= 0
                || inc == 1 && ((Comparable) end).compareTo(current) >= 0;

        return retVal;
      }
Example #3
0
 public boolean isEven() {
   return n.intValue() % 2 == 0;
 }
Example #4
0
 public int intSize() {
   return end.intValue() - begin.intValue();
 }
Example #5
0
 public int intValue() {
   return mValue.intValue();
 }
Example #6
0
 public int compareTo(T o) {
   return o.intValue();
 }
Example #7
0
 public boolean matches(T number) {
   return number.intValue() == 0 || number.intValue() == 1;
 }
Example #8
0
 double fraction() {
   return num.doubleValue() - num.intValue();
 }