List

Description

This data structure will contain a sequence of Node objects, each which will have a reference to the next.

Relationships

  • Node : Uses the Node data object to populate with.

Members

  • Node head - the head element in the data structure
  • Node tail - the tail element in the data structure
  • int count - this indicates the number of data values that is contained in the data structure

Methods

  • List(Node list, int count) - base constructor
    • sets the head and tail Node values to the list parameter and sets the count value to the count parameter
    • then loops through, using count as the end value, and for each iteration sets the tail value to the next item of the tail (eg tail = tail.Next)
  • List(Node head)
    • calls the base constructor, passing in the head Node and a count of 1
  • List()
    • calls the base constructor, passing in null for the Node object and 0 for the count
  • Clear()
    • sets the head and tail Nodes to null and sets the count to 0
  • Add(Node node)
    • adds the node parameter to the end of the list, updating the previous node's next property
  • Insert(Node node, int index)
    • returns a bool indicating if the insertion was successful - this inserts the node parameter at the desired index
  • Replace(Node node, int index)
    • returns a bool indicating the success of the replacement of a the item parameter at the specified index
  • InsertHead(Node node)
    • inserts an item at the head slot of the list and sets the head value to the new item
  • Remove(Node node)
    • removes the node parameter from the list container
  • Get(int index)
    • returns a node object from the parameter index
  • Contains(Node node)
    • returns a bool indicating whether the node parameter is contained in the list
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License