jist.swans.misc
Class SingletonInt

java.lang.Object
  extended by jist.swans.misc.SingletonInt

public class SingletonInt
extends java.lang.Object

Class to store a mutable primitive integer with in an Object (because Java has primitives in the first place).

Since:
SWANS1.0
Version:
$Id: SingletonInt.java,v 1.4 2004/04/06 16:07:49 barr Exp $
Author:
Rimon Barr <barr+jist@cs.cornell.edu>

Field Summary
 int i
          encapsulated integer.
private static java.lang.Integer[] INTS
          Array of (commonly requested) Integer object for small integer primitives.
 
Constructor Summary
SingletonInt()
          Create a new singleton integer with value zero.
SingletonInt(int i)
          Create a new singleton integer with given value.
 
Method Summary
static java.lang.Integer getSmallInteger(int i)
          Return the Integer for a small integer, hopefully without a new allocation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

i

public int i
encapsulated integer.


INTS

private static final java.lang.Integer[] INTS
Array of (commonly requested) Integer object for small integer primitives.

Constructor Detail

SingletonInt

public SingletonInt()
Create a new singleton integer with value zero.


SingletonInt

public SingletonInt(int i)
Create a new singleton integer with given value.

Parameters:
i - initial singleton integer value
Method Detail

getSmallInteger

public static java.lang.Integer getSmallInteger(int i)
Return the Integer for a small integer, hopefully without a new allocation.

Parameters:
i - some integer to convert to an Integer
Returns:
Integer object corresponding integer primitive