FileDocCategorySizeDatePackage
PieceListImpl.javaAPI DocAzureus 3.0.3.42191Sun Jul 15 17:04:26 BST 2007org.gudy.azureus2.core3.disk.impl.piecemapper.impl

PieceListImpl

public class PieceListImpl extends Object implements org.gudy.azureus2.core3.disk.impl.piecemapper.DMPieceList
author
Moti PieceList contains a list of pieces; it also provides accessor and utility methods.

Fields Summary
private final PieceMapEntryImpl[]
pieces
private final int[]
cumulativeLengths
Constructors Summary
protected PieceListImpl(PieceMapEntryImpl[] _pieces)

		pieces = _pieces;
		cumulativeLengths = new int[pieces.length];
		
		initializeCumulativeLengths();
	
Methods Summary
public static org.gudy.azureus2.core3.disk.impl.piecemapper.impl.PieceListImplconvert(java.util.List pieceList)

		return new PieceListImpl((PieceMapEntryImpl[])pieceList.toArray(new PieceMapEntryImpl[pieceList.size()]));	
	
public org.gudy.azureus2.core3.disk.impl.piecemapper.DMPieceMapEntryget(int index)

		return pieces[index];	
	
public intgetCumulativeLengthToPiece(int index)

		return cumulativeLengths[index];	
	
private voidinitializeCumulativeLengths()

		int runningLength = 0;
		for (int i = 0; i < pieces.length; i++) {
			runningLength += pieces[i].getLength();
			cumulativeLengths[i] = runningLength;
		}
	
public intsize()

		return pieces.length;