ewe.util
Class LinkedListElement

java.lang.Object
  extended byewe.util.LinkedListElement
Direct Known Subclasses:
DisplayLine

public class LinkedListElement
extends Object

This is a utility class which can be the building blocks of linked list implementation. It has a native method to quickly traverse the list in both direction.


Field Summary
 LinkedListElement next
           
 LinkedListElement prev
           
 
Constructor Summary
LinkedListElement()
           
 
Method Summary
static void addSectionAfter(LinkedListElement after, LinkedListElement startToAdd)
           
static void addSectionBefore(LinkedListElement before, LinkedListElement startToAdd)
           
static int countInRange(LinkedListElement start, LinkedListElement end)
          Counts the number of elements in the inclusive range start -> end.
static int countNext(LinkedListElement start)
          Count how many are in the list starting from (and including) start.
static int countPrev(LinkedListElement start)
          Count how many are in the list starting from (and including) start going backwards.
static LinkedListElement getNext(LinkedListElement start, int elements)
          Starting from the "start" element count "elements" units down.
static LinkedListElement getPrev(LinkedListElement start, int elements)
          Starting from the "start" element count "elements" units back.
static void removeSection(LinkedListElement start, LinkedListElement last)
           
static void replaceSection(LinkedListElement start, LinkedListElement end, LinkedListElement newSection)
          This replaces a section of elements with a new section.
static void toArray(LinkedListElement first, int length, LinkedListElement[] elements)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, toString
 

Field Detail

next

public LinkedListElement next

prev

public LinkedListElement prev
Constructor Detail

LinkedListElement

public LinkedListElement()
Method Detail

getNext

public static LinkedListElement getNext(LinkedListElement start,
                                        int elements)
Starting from the "start" element count "elements" units down. Returns null if it runs out of elements. If elements is negative, it will return the last element in the chain.


getPrev

public static LinkedListElement getPrev(LinkedListElement start,
                                        int elements)
Starting from the "start" element count "elements" units back. Returns null if it runs out of elements. If elements is negative, it will return the first element in the chain.


removeSection

public static void removeSection(LinkedListElement start,
                                 LinkedListElement last)

addSectionAfter

public static void addSectionAfter(LinkedListElement after,
                                   LinkedListElement startToAdd)

addSectionBefore

public static void addSectionBefore(LinkedListElement before,
                                    LinkedListElement startToAdd)

replaceSection

public static void replaceSection(LinkedListElement start,
                                  LinkedListElement end,
                                  LinkedListElement newSection)
This replaces a section of elements with a new section. The oldsection has its two ends terminated with nulls so that it can be placed in a different list.


countNext

public static int countNext(LinkedListElement start)
Count how many are in the list starting from (and including) start.


countPrev

public static int countPrev(LinkedListElement start)
Count how many are in the list starting from (and including) start going backwards.


countInRange

public static int countInRange(LinkedListElement start,
                               LinkedListElement end)
Counts the number of elements in the inclusive range start -> end. If the end parameter is null it counts from the start to the end of the list. If the start parameter is null it counts from end backwards to the start of the list.


toArray

public static void toArray(LinkedListElement first,
                           int length,
                           LinkedListElement[] elements)