com.browseengine.bobo.util
Class SparseFloatArray

java.lang.Object
  extended by com.browseengine.bobo.util.SparseFloatArray
Direct Known Subclasses:
MutableSparseFloatArray

public class SparseFloatArray
extends Object

Author:
spackle

Constructor Summary
SparseFloatArray(float[] floats)
          Good for saving memory with sparse float arrays, when those arrays no longer need to be mutable.
SparseFloatArray(int capacity)
          Short-cut to quickly create a sparse float array representing this(new float[capacity]);, but without reading through said array.
 
Method Summary
 float[] expand()
          warning: DO NOT modify the return value at all.
 float get(int idx)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SparseFloatArray

public SparseFloatArray(float[] floats)
Good for saving memory with sparse float arrays, when those arrays no longer need to be mutable. requires: floats never changes after this method is called returns. in fact, you should lose all references to it, since this object might save you a lot of memory.

Parameters:
floats -

SparseFloatArray

public SparseFloatArray(int capacity)
Short-cut to quickly create a sparse float array representing this(new float[capacity]);, but without reading through said array. The advantage here is that the constructor is lightning-fast in the case that all values in the float array are known to
 == 0f
 
 .

Parameters:
capacity -
Method Detail

expand

public float[] expand()
warning: DO NOT modify the return value at all. the assumption is that these arrays are QUITE LARGE and that we would not want to unnecessarily copy them. this method in many cases returns an array from its internal representation. doing anything other than READING these values results in UNDEFINED operations on this, from that point on.

Returns:

get

public float get(int idx)


Copyright © 2011. All Rights Reserved.