MySortedSLL - import java.io.*;...

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

View Full Document Right Arrow Icon
import java.io.*; @SuppressWarnings("unchecked") public class MySortedSLL<E> implements Serializable { private MySLLNode<E> head; // Default Constructor public MySortedSLL() { head=null; } public int size() { MySLLNode<E> mslln = head; int i = 0; for(; mslln !=null; mslln = mslln.getNext()) { i++; } return i; } public E getFirst() { if (head != null) { return head.getData(); } else { return null; } } public E getLast() { MySLLNode<E> mslln = head; MySLLNode<E> last = null; for(; mslln != null; mslln = mslln.getNext()) { last = mslln; } if (last != null) { return last.getData(); } else { return null; } } public E get(int index) throws IndexOutOfBoundsException { MySLLNode<E> mslln = head; int i; for (i = 0; i< index & mslln != null; i++)
Background image of page 1

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

View Full DocumentRight Arrow Icon
{ mslln = mslln.getNext(); } if( i != index || mslln == null) throw new IndexOutOfBoundsException(); else return mslln.getData(); } public void add(E obj) throws ClassCastException { if ( !(obj instanceof Comparable)) throw new ClassCastException(); t Comparable comp = (Comparable)obj;
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 03/25/2010 for the course CIS CIS3023 taught by Professor Seema during the Spring '10 term at Florida College.

Page1 / 3

MySortedSLL - import java.io.*;...

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