http://www.keirsey.com/
If you care about mine, I
tend to vary, but generally come out as an INTP.
http://www.math.grin.edu/~rebelsky/Courses/152/97F/html-survey.html
/** Initialize a list with a maximum size */
public IntList(int maxsize) throws Exception {
// Create the two arrays
contents = new int[maxsize];
if (contents == null) {
throw new Exception("Insufficient memory");
}
next = new int[maxsize];
if (next == null) {
contents = null; // So it can be reclaimed
throw new Exception("Insufficient memory");
}
// Set up the free list
for(int i = 0; i < maxsize-2; ++i) {
next[i] = i+1;
}
next[maxsize-1] = NULL_INDEX;
for(int i = 1; i < maxsize-1; ++i) {
prev[i] = i-1;
}
prev[0] = NULL_INDEX;
// Set up the actual list
front = NULL_INDEX;
back = NULL_INDEX;
} // IntList(int)
public void insertAtHead(int i) throws ListException {
// Sanity check
if (free == NULL_INDEX) {
throw new ListException("Insufficient room");
}
// Grab the front of the free list
int new_front = free;
free = next[free];
if (free != NULL_INDEX {
prev[free] = NULL_INDEX;
}
// Update the contents and next pointer of the new element
contents[new_front] = i;
next[new_front] = front;
prev[new_front] = NULL_INDEX;
// Update the prev pointer of the old front
if (front != NULL_INDEX) { prev[front] = new_front; }
// Update the front of the lsit
front = new_front;
} // insertAtHead
public int deleteLast() throws ListException {
// Sanity check
if (front == NULL_INDEX) {
throw new ListException("Can't delete from empty list");
}
// The index of the element we're deleting
int deleting = last;
// Update the last element
last = prev[last];
if (last != NULL_INDEX]) { next[last] = NULL_INDEX; }
// Update the front if necessary
if (front == deleting) { front = NULL_INDEX; }
// Update the free list by placing deleted element at front
next[deleting] = free;
prev[deleting] = NULL_INDEX;
if (free != NULL_INDEX) { prev[free] = deleting; }
free = deleting;
// We're done
return contents[deleting];
} // deleteLast
Disclaimer Often, these pages were created "on the fly" with little, if any, proofreading. Any or all of the information on the pages may be incorrect. Please contact me if you notice errors.
Source text last modified Wed Oct 15 11:01:10 1997.
This page generated on Wed Nov 5 12:38:31 1997 by SiteWeaver.
Contact our webmaster at rebelsky@math.grin.edu