Package org.apache.mahout.math.list

Examples of org.apache.mahout.math.list.ShortArrayList


  /**
   * Returns a string representation of the receiver, containing the String representation of each key-value pair,
   * sorted ascending by key.
   */
  public String toString() {
    ShortArrayList theKeys = keys();
    //theKeys.sort();

    StringBuilder buf = new StringBuilder();
    buf.append('[');
    int maxIndex = theKeys.size() - 1;
    for (int i = 0; i <= maxIndex; i++) {
      short key = theKeys.get(i);
      buf.append(String.valueOf(key));
      buf.append("->");
      buf.append(String.valueOf(get(key)));
      if (i < maxIndex) {
        buf.append(", ");
View Full Code Here


  /**
   * Returns a string representation of the receiver, containing the String representation of each key-value pair,
   * sorted ascending by value.
   */
  public String toStringByValue() {
    ShortArrayList theKeys = new ShortArrayList();
    keysSortedByValue(theKeys);

    StringBuilder buf = new StringBuilder();
    buf.append('[');
    int maxIndex = theKeys.size() - 1;
    for (int i = 0; i <= maxIndex; i++) {
      short key = theKeys.get(i);
      buf.append(String.valueOf(key));
      buf.append("->");
      buf.append(String.valueOf(get(key)));
      if (i < maxIndex) {
        buf.append(", ");
View Full Code Here

                return (first % 2) != 0;
            }
        });
        CharArrayList keyList = new CharArrayList(map.keySet().toCharArray());
        keyList.sort();
        ShortArrayList valueList = new ShortArrayList(map.values().toShortArray());
        valueList.sort();
        assertEquals(2, keyList.size());
        assertEquals(2, valueList.size());
        assertEquals(12, keyList.get(0) /* keyEpsilon */);
        assertEquals(14, keyList.get(1) /* keyEpsilon */);
        assertEquals(23, valueList.get(0) /* valueEpsilon */);
        assertEquals(25, valueList.get(1) /* valueEpsilon */);
    }
View Full Code Here

        map.put((char) 11, (short) 22);
        map.put((char) 12, (short) 23);
        map.put((char) 13, (short) 24);
        map.put((char) 14, (short) 25);
        map.remove((char) 13);
        ShortArrayList values = new ShortArrayList(map.values().toShortArray());
        assertEquals(3, values.size());
        values.sort();
        assertEquals(22, values.get(0) /* valueEpsilon */);
        assertEquals(23, values.get(1) /* valueEpsilon */);
        assertEquals(25, values.get(2) /* valueEpsilon */);
    }
View Full Code Here

TOP

Related Classes of org.apache.mahout.math.list.ShortArrayList

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.