FileDocCategorySizeDatePackage
SnmpMib.javaAPI DocJava SE 5 API31036Fri Aug 26 14:55:04 BST 2005com.sun.jmx.snmp.agent

LongList

public final class LongList extends Object
This list is used in order to construct the OID during the getnext. The constructed oid is checked by the checker AcmChecker.

Fields Summary
public static int
DEFAULT_CAPACITY
public static int
DEFAULT_INCREMENT
private final int
DELTA
private int
size
public long[]
list
The list content. Any access to this variable must be protected by a synchronized block on the LongList object. Only read-only action should be performed on this object.
Constructors Summary
LongList()

    
     
        this(DEFAULT_CAPACITY,DEFAULT_INCREMENT);
    
LongList(int initialCapacity)

        this(initialCapacity,DEFAULT_INCREMENT);
    
LongList(int initialCapacity, int delta)

        size = 0; 
        DELTA = delta;
        list = allocate(initialCapacity);
    
Methods Summary
public final booleanadd(long o)
Same behaviour than add(long o) in {@link java.util.List}. Any access to this method should be protected in a synchronized block on the LongList object.

        if (size >= list.length) 
            resize();
        list[size++]=o;
        return true;
    
public final voidadd(int index, long o)
Same behaviour than add(int index, long o) in {@link java.util.List}. Any access to this method should be protected in a synchronized block on the LongList object.

        if (index >  size) throw new IndexOutOfBoundsException();
        if (index >= list.length) resize();
        if (index == size) {
            list[size++]=o;
            return;
        }
	
        java.lang.System.arraycopy(list,index,list,index+1,size-index);
        list[index]=o;
        size++;
    
public final voidadd(int at, long[] src, int from, int count)
Adds count elements to the list.

param
at index at which the elements must be inserted. The first element will be inserted at this index.
param
src An array containing the elements we want to insert.
param
from Index of the first element from src that must be inserted.
param
count number of elements to insert. Any access to this method should be protected in a synchronized block on the LongList object.

	if (count <= 0) return;
	if (at > size) throw new IndexOutOfBoundsException();
	ensure(size+count);
	if (at < size) {
	    java.lang.System.arraycopy(list,at,list,at+count,size-at);
	}
	java.lang.System.arraycopy(src,from,list,at,count);
	size+=count;	
    
private final long[]allocate(int length)
Allocate a new array of object of specified length.

        return new long[length];
    
private final voidensure(int length)
Resize the list. Insure that the new length will be at least equal to length.

param
length new minimal length requested. Any call to this method must be protected by a synchronized block on this LongList.

	if (list.length < length) {
	    final int min = list.length+DELTA;
	    length=(length<min)?min:length;
	    final long[] newlist = allocate(length);
	    java.lang.System.arraycopy(list,0,newlist,0,size);
	    list = newlist;
	}
    
public final longremove(int from, int count)
Any access to this method should be protected in a synchronized block on the LongList object.

        if (count < 1 || from < 0) return -1;
        if (from+count > size) return -1;

        final long o = list[from];
	final int oldsize = size;
	size = size - count;

        if (from == size) return o;
	
        java.lang.System.arraycopy(list,from+count,list,from,
                                   size-from);
        return o;
    
public final longremove(int index)
Same behaviour than remove(int index) in {@link java.util.List}. Any access to this method should be protected in a synchronized block on the LongList object.

        if (index >= size) return -1;
        final long o = list[index];
        list[index]=0;
        if (index == --size) return o;
	
        java.lang.System.arraycopy(list,index+1,list,index,
                                   size-index);
        return o;
    
private final voidresize()
Resize the list. Increase its capacity by DELTA elements. Any call to this method must be protected by a synchronized block on this LongList.

        final long[] newlist = allocate(list.length + DELTA);
        java.lang.System.arraycopy(list,0,newlist,0,size);
        list = newlist;
    
public final intsize()
Same behaviour than size() in {@link java.util.List}.

 return size;
public final long[]toArray(long[] a)
Same behaviour than the toArray(long[] a) method in {@link java.util.List}. Any access to this method should be protected in a synchronized block on the LongList object.

        java.lang.System.arraycopy(list,0,a,0,size);
        return a;
    
public final long[]toArray()
Same behaviour than the toArray() method in {@link java.util.List}. Any access to this method should be protected in a synchronized block on the LongList object.

        return toArray(new long[size]);