/**
   * returns a subset of this column with entried from rows indicated by <code>indices</code>.
   *
   * @param indices row numbers to include in the returned subset.
   * @return a subset of this column, including rows indicated by <code>indices</code>.
   */
  public Column getSubset(int[] indices) {
    SparseObjectColumn retVal = new SparseObjectColumn(indices.length);
    for (int i = 0; i < indices.length; i++) {
      if (elements.containsKey(indices[i])) {

        // XIAOLEI
        // retVal.setObject(getObject(indices[i]), indices[i]);
        retVal.setObject(getObject(indices[i]), i);
      }
    }
    super.getSubset(retVal, indices);

    return retVal;
  }
  /**
   * performs a deep copy of this SparseObjectColumn returns an exact copy of this
   * SparseObjectColumn
   *
   * @return a SparseObjectColumn object which is a deep copy of this SparseObjectColumn.
   */
  public Column copy() {
    SparseObjectColumn retVal;
    try {
      ByteArrayOutputStream baos = new ByteArrayOutputStream();
      ObjectOutputStream oos = new ObjectOutputStream(baos);
      oos.writeObject(this);
      byte buf[] = baos.toByteArray();
      oos.close();
      ByteArrayInputStream bais = new ByteArrayInputStream(buf);
      ObjectInputStream ois = new ObjectInputStream(bais);
      retVal = (SparseObjectColumn) ois.readObject();
      ois.close();
      return retVal;
    } catch (Exception e) {

      retVal = new SparseObjectColumn();
      retVal.copy(this);

      return retVal;
    }
  }
  /**
   * Returns a SparseObjectColumn that holds only the data from rows <code>
   * pos</code> through <code>pos+len</code>
   *
   * @param pos the row number which is the beginning of the subset
   * @param len number of consequetive rows after <code>pos</code> that are to be included in the
   *     subset.
   * @return a SparseObjectColumn with the data from rows <code>pos</code> through <code>pos+len
   *     </code>
   */
  public Column getSubset(int pos, int len) {
    SparseObjectColumn subCol = new SparseObjectColumn();
    subCol.elements = (VIntObjectHashMap) elements.getSubset(pos, len);
    getSubset(subCol, pos, len);

    return subCol;
    /*
        //the map to hold the data of the subset
         VIntObjectHashMap tempMap = new VIntObjectHashMap(len);
         //for each Object from pos till pos+len
         for (int i=0; i<len; i++)
    //if a value is mapped to current inspected row number
    if(elements.containsKey(pos+i))
     //put it in the new map
     tempMap.put(pos+i, getObject(pos+i));
        SparseObjectColumn subCol = new SparseObjectColumn();   //the returned value
        super.copy(subCol);     //copying general attributes
        //activating copy method in order to have a deep copy of the subset
        subCol.elements = tempMap.copy();    //linking the data to the returned value
         return subCol;
    */
  }
 /**
  * Reorders the data stored in this column in a new column. Does not change this column.
  *
  * <p>Algorithm: copy this column into the returned vlaue. for each pair (key, val) in <code>
  * newOrder</code>, if val is a valid row in this column, put the value mapped to it in row no.
  * key in the returned values.
  *
  * @param newOrder - an int to int hashmap, defining the new order for the returned column.
  * @return a SparseObjectColumn ordered according to <code>newOrder</code>.
  */
 public Column reorderRows(VIntIntHashMap newOrder) {
   SparseObjectColumn retVal = new SparseObjectColumn();
   retVal.elements = (VIntObjectHashMap) elements.reorder(newOrder);
   reorderRows(retVal, newOrder);
   return retVal;
 }