javax.realtime
Class SizeEstimator

java.lang.Object
  extended byjavax.realtime.SizeEstimator

public final class SizeEstimator
extends Object

This is a convenient class to help people figure out how much memory they need. Instead of passing actual numbers to the MemoryArea constructors, one can pass SizeEstimator objects with which you can have a better feel of how big a memory area you require.

Author:
Angelo Corsaro, Morgan Deters

Constructor Summary
SizeEstimator()
          Construct a SizeEstimator.
 
Method Summary
 long getEstimate()
          Returns an estimate of the number of bytes needed to store all the objects reserved.
 void reserve(Class c, int n)
          Take into account additional n instances of class c when estimating the size of the MemoryArea.
 void reserve(SizeEstimator s)
          Take into account an additional instance of SizeEstimator when estimating the size of the MemoryArea.
 void reserve(SizeEstimator s, int n)
          Take into account additional n instances of SizeEstimator when estimating the size of the MemoryArea.
 void reserveArray(int length)
          Reserve room in this SizeEstimator for an instance of a reference array of size length.
 void reserveArray(int length, Class type)
          Reserve room in this SizeEstimator for an instance of an array of primitive values of size length.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SizeEstimator

public SizeEstimator()
Construct a SizeEstimator.

Method Detail

getEstimate

public long getEstimate()
Returns an estimate of the number of bytes needed to store all the objects reserved.

Returns:
the estimate.

reserve

public void reserve(Class c,
                    int n)
Take into account additional n instances of class c when estimating the size of the MemoryArea.

Parameters:
c - the class to be considered
n - the number of instances for which memory needs to be reserved.

reserve

public void reserve(SizeEstimator s)
Take into account an additional instance of SizeEstimator when estimating the size of the MemoryArea.

Parameters:
s - a SizeEstimator

reserve

public void reserve(SizeEstimator s,
                    int n)
Take into account additional n instances of SizeEstimator when estimating the size of the MemoryArea.

Parameters:
s - a SizeEstimator value
n - the number of instances.

reserveArray

public void reserveArray(int length)
Reserve room in this SizeEstimator for an instance of a reference array of size length.

Parameters:
length - the size of the array to include in the estimate
Throws:
IllegalArgumentException - if length is negative

reserveArray

public void reserveArray(int length,
                         Class type)
Reserve room in this SizeEstimator for an instance of an array of primitive values of size length.

Parameters:
length - the size of the array to include in the estimate
type - the class representing a primitive type to use for the array estimate
Throws:
IllegalArgumentException - if length is negative


jRate is developed and maintained by the jRate project development team.
Copyright (c) 2001-2006 Angelo Corsaro and Morgan Deters.