/** {@inheritDoc} */ public TFloatList grep( TFloatProcedure condition ) { TFloatArrayList list = new TFloatArrayList(); for ( int i = 0; i < _pos; i++ ) { if ( condition.execute( _data[ i ] ) ) { list.add( _data[ i ] ); } } return list; }
for (int i = 0; i < posize; i++) { nweights[i] = models[i].getWeights(); ww[i] = new TFloatArrayList(); for (int l = 0; l < posize; l++) { for (int j = 0; j < interv; j++) { ww[l].insert(id + j, nweights[l][base + j]); models[l].setWeights(ww[l].toArray()); ww[l].clear();
/** * Creates a new <code>TFloatArrayStack</code> instance with the * specified capacity. * * @param capacity the initial depth of the stack * @param no_entry_value value that represents null */ public TFloatArrayStack( int capacity, float no_entry_value ) { _list = new TFloatArrayList( capacity, no_entry_value ); }
public void add(int id, float priority) { float lowestPriority = Float.NEGATIVE_INFINITY; if (priorities.size() > 0) { lowestPriority = priorities.get(priorities.size() - 1); priorities.add(priority); } else if (priority > lowestPriority) { if (ids.size() >= preferredMaximumSize) { int lowestPriorityIndex = ids.size() - 1; while ((lowestPriorityIndex - 1 >= 0) && (priorities.get(lowestPriorityIndex - 1) == lowestPriority)) { lowestPriorityIndex--; priorities.remove(lowestPriorityIndex, priorities.size() - lowestPriorityIndex); while (insertPosition - 1 >= 0 && priority > priorities.get(insertPosition - 1)) { insertPosition--; priorities.insert(insertPosition, priority);
public float[] getPointCloudBuffer() { TFloatArrayList pointCloudBuffer = new TFloatArrayList(); for (int i = 0; i < numberOfPoints; i++) { Point3D scanPoint = pointCloud[i]; pointCloudBuffer.add((float) scanPoint.getX()); pointCloudBuffer.add((float) scanPoint.getY()); pointCloudBuffer.add((float) scanPoint.getZ()); } return pointCloudBuffer.toArray(); }
/** * Pushes the value onto the top of the stack. * * @param val an <code>float</code> value */ public void push( float val ) { _list.add( val ); }
/** * Returns the current depth of the stack. */ public int size() { return _list.size(); }
/** {@inheritDoc} */ public float[] toArray( float[] dest ) { int len = dest.length; if ( dest.length > _pos ) { len = _pos; dest[len] = no_entry_value; } toArray( dest, 0, len ); return dest; }
/** {@inheritDoc} */ public void insert( int offset, float value ) { if ( offset == _pos ) { add( value ); return; } ensureCapacity( _pos + 1 ); // shift right System.arraycopy( _data, offset, _data, offset + 1, _pos - offset ); // insert _data[ offset ] = value; _pos++; }
private void promote(int index, int value, float priority) { // Consider the index to be a "hole"; i.e. don't swap priorities/values // when moving up the tree, simply copy the parent into the hole and // then consider the parent to be the hole. // Finally, copy the value/priority into the hole. while (index > 0) { int parentIndex = (index - 1) / 2; float parentPriority = priorities.get(parentIndex); if (sortsEarlierThan(parentPriority, priority)) { break; } // copy the parent entry into the current index. values.set(index, values.get(parentIndex)); priorities.set(index, parentPriority); index = parentIndex; } values.set(index, value); priorities.set(index, priority); if (INTERNAL_CONSISTENCY_CHECKING) { check(); } }
/** {@inheritDoc} */ public float next() { try { float next = get( cursor ); lastRet = cursor++; return next; } catch ( IndexOutOfBoundsException e ) { throw new NoSuchElementException(); } }
/** * Clears the stack. */ public void clear() { _list.clear(); }
/** {@inheritDoc} */ public boolean removeAll( TFloatCollection collection ) { if ( collection == this ) { clear(); return true; } boolean changed = false; TFloatIterator iter = collection.iterator(); while ( iter.hasNext() ) { float element = iter.next(); if ( remove( element ) ) { changed = true; } } return changed; }
/** * Copies a slice of the list into a native array. Note that this will NOT * pop them out of the stack. The front of the list will be the top * of the stack. * <p> * If the native array is smaller than the stack depth, * the native array will be filled with the elements from the top * of the array until it is full and exclude the remainder. * * @param dest the array to copy into. */ public void toArray( float[] dest ) { int size = size(); int start = size - dest.length; if ( start < 0 ) { start = 0; } int length = Math.min( size, dest.length ); _list.toArray( dest, start, length ); reverse( dest, 0, length ); if ( dest.length > size ) { dest[size] = _list.getNoEntryValue(); } }