All pastes #31653 Raw Edit

Unnamed

public text v1 · immutable
#31653 ·published 2005-11-29 05:06 UTC
rendered paste body
// Source code example for "A Practical Introduction
// to Data Structures and Algorithm Analysis"
// by Clifford A. Shaffer, Prentice Hall, 1998.
// Copyright 1998 by Clifford A. Shaffer

public class Link {         // A singly linked list node

  private Object element;   // Object for this node
  private Link next;        // Pointer to next node in list
  private int num;

  Link(Object it,int n, Link nextval) {         // Constructor 1
    element = it;
    next = nextval;
    num = n;
  }   //  Given Object

  Link(Link nextval) {
	next = nextval;
  } // Constructor 2

  Link next() {
	return next;
  }

  Link setNext(Link nextval) {
	next = nextval;
	return next;
  }

  Object element() {
	return element;
  }
  
  int priority() {
	  return num;
  }

  Object setElement(Object it) {
	element = it;
	return element;
  }
  
  int setPriority(int i) {
	  num = i;
	  return i;
  }

} // class Link