Doubly Linked List

Situations for using a Doubly Linked list would be

  • deck of cards
  • browser cache
  • Metro

A new node’s previous points left, and next points right. When we add a new node, we pass in the linked list’s tail into the new Node’s constructor.

The new Node will re-wire it so that its previous points to the last node of the linked list (via the tail).

Then have the next of the last node point to the new Node.

Then, the linked list will proceed to re-assign the tail to the new node. Thus, completing the push.

Also, each node is connected with each by 2 traits:

  • The first node’s next points to the second node. The first node’s previous points to the node on its left side. (or bottom, if you are looking at it vertically)
  • The second node’s previous points to the first node. And its next points to the node on its right side. (or top, if you are looking at it vertically)

Getter/Setters

Getter setter is done by first declaring a name that matches your property but with a capital first letter. Then, you use keywords get and write a function for when you retrieve the property.

Use keyword set to write a function where you assign another value to your property. The incoming value is designated as keyword “value”. The value keyword is a contextual keyword, that is, it has a different meaning based on its context.

Inside a set block, it simply means the value that the programmer has set it to.

Outside of a set block, you can use value as a variable identifier, as such:
int value = 5;

You’d use it like this:

myList.Count = 222;

Doubly Linked List source