Package cern.colt.list

Examples of cern.colt.list.IntArrayList


    setUp(rows, columns);
  }
  catch (IllegalArgumentException exc) { // we can hold rows*columns>Integer.MAX_VALUE cells !
    if (! "matrix too large".equals(exc.getMessage())) throw exc;
  }
  indexes = new IntArrayList();
  values = new DoubleArrayList();
  starts = new int[rows+1];
}
View Full Code Here


public void setQuick(int row, int column, double value) {
  int i=row;
  int j=column;
 
  int k=-1;
  IntArrayList indexList = indexes[i];
  if (indexList != null) k = indexList.binarySearch(j);
 
  if (k>=0) { // found
    if (value==0) {
      DoubleArrayList valueList = values[i];
      indexList.remove(k);
      valueList.remove(k);
      int s = indexList.size();
      if (s>2 && s*3 < indexList.elements().length) {
        indexList.setSize(s*3/2);
        indexList.trimToSize();
        indexList.setSize(s);
       
        valueList.setSize(s*3/2);
        valueList.trimToSize();
        valueList.setSize(s);   
      }
    }
    else {
      values[i].setQuick(k,value);
    }
  }
  else { // not found
    if (value==0) return;

    k = -k-1;

    if (indexList == null) {
      indexes[i] = new IntArrayList(3);
      values[i= new DoubleArrayList(3);
    }
    indexes[i].beforeInsert(k,j);
    values[i].beforeInsert(k,value);
  }
View Full Code Here

/**
*/
public static void doubleTest30(int size) {

int[] values = { 0, 2, 3, 5, 7};
IntArrayList list = new IntArrayList(values);
int val = 3;
int sum=0;
cern.colt.Timer timer = new cern.colt.Timer().start();
for (int i=size; --i>=0; ) {
  int k = list.binarySearchFromTo(val,0,values.length-1);
  System.out.println(list+", "+val+" --> "+k);
  sum+=k;
}
timer.stop().display();
//System.out.println("sum = "+sum);
View Full Code Here

*/
public static void doubleTest30(int size, int val) {

//int[] values = { 0, 2};
int[] values = {2};
IntArrayList list = new IntArrayList(values);
int l = values.length-1;
int sum=0;
cern.colt.Timer timer = new cern.colt.Timer().start();
for (int i=size; --i>=0; ) {
  int k = cern.colt.Sorting.binarySearchFromTo(values,val,0,l);
View Full Code Here

* This method can be used to iterate over the keys of the receiver.
*
* @return the keys.
*/
public IntArrayList keys() {
  IntArrayList list = new IntArrayList(size());
  keys(list);
  return list;
}
View Full Code Here

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

  StringBuffer buf = new StringBuffer(tmp);
  //StringBuffer buf = new StringBuffer();
  buf.append("[");
  int maxIndex = theKeys.size() - 1;
  for (int i = 0; i <= maxIndex; i++) {
    int 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() {
  IntArrayList theKeys = new IntArrayList();
  keysSortedByValue(theKeys);

  StringBuffer buf = new StringBuffer();
  buf.append("[");
  int maxIndex = theKeys.size() - 1;
  for (int i = 0; i <= maxIndex; i++) {
    int 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

@param  condition The condition to be matched.
@return the new view.
*/
public DoubleMatrix2D viewSelection(DoubleMatrix1DProcedure condition) {
  IntArrayList matches = new IntArrayList();
  for (int i=0; i < rows; i++) {
    if (condition.apply(viewRow(i))) matches.add(i);
  }
 
  matches.trimToSize();
  return viewSelection(matches.elements(), null); // take all columns
}
View Full Code Here

@param  condition The condition to be matched.
@return the new view.
*/
public ObjectMatrix2D viewSelection(ObjectMatrix1DProcedure condition) {
  IntArrayList matches = new IntArrayList();
  for (int i=0; i < rows; i++) {
    if (condition.apply(viewRow(i))) matches.add(i);
  }
 
  matches.trimToSize();
  return viewSelection(matches.elements(), null); // take all columns
}
View Full Code Here

@param  condition The condition to be matched.
@return the new view.
*/
public ObjectMatrix1D viewSelection(cern.colt.function.ObjectProcedure condition) {
  IntArrayList matches = new IntArrayList();
  for (int i=0; i < size; i++) {
    if (condition.apply(getQuick(i))) matches.add(i);
  }
  matches.trimToSize();
  return viewSelection(matches.elements());
}
View Full Code Here

TOP

Related Classes of cern.colt.list.IntArrayList

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.