notes44 - 1/29/07 Implementing Ranked Sequences using...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
1/29/07 Implementing Ranked Sequences using Double Linked Lists DLLNode.java: class DLLNode { public: DLLNode _previous; DLLNode _next; Object _value; } DLLRankedSequence.java class DLLRankedSequence { int _n; //number of elements DLLNode _header; DLLNode _tail; public DLLRankedSequence() { _header = new DLLNode(); _tail = new DLLNode(); _header._next = _tail; _header._previous = _header; _tail._next = _header; _tail._previous = _header; _header._value = null; _tail._value = null; _n = 0; } DLLNode nodeAtRank (int max) throws OutofBoundsException { if ((index < 0) || index >= _N) throw new OutofBoundsException int i = 0; DLLNode node = _header._next; while (i<index) { node = node._next; i++; } return node; } void insertElementAtRank(int index, Object value) throws OutofBoundsException { DLLNode node; {
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
//between limits node = nodeAtRank(index); } else if (index == n) { //Insert at the end of list node = tail; } else {// out of range throw new OutofBoundsException();
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 02/02/2012 for the course CS 251 taught by Professor Staff during the Fall '08 term at Purdue University-West Lafayette.

Page1 / 4

notes44 - 1/29/07 Implementing Ranked Sequences using...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online