feisty meow concerns codebase  2.140
nodes::singly_linked_list Class Reference

Implements a singly-linked list structure. More...

#include <singly_linked_list.h>

Inheritance diagram for nodes::singly_linked_list:
Collaboration diagram for nodes::singly_linked_list:

Public Member Functions

 singly_linked_list ()
 
 ~singly_linked_list ()
 
int elements () const
 returns the number of items currently in the list, including this node. More...
 
singly_linked_listnext ()
 
void set_next (singly_linked_list *new_next)
 
- Public Member Functions inherited from nodes::node
 node (int number_of_links=0)
 the constructor provides for "number_of_links" links initially. More...
 
virtual ~node ()
 the destructor simply invalidates the node. More...
 
int links () const
 Returns the number of links the node currently holds. More...
 
void set_link (int link_number, node *new_link)
 Connects the node "new_link" to this node. More...
 
nodeget_link (int link_number) const
 Returns the node that is connected to the specified "link_number". More...
 
void zap_link (int link_number)
 the specified link is removed from the node. More...
 
void insert_link (int where, node *to_add=NULL_POINTER)
 adds a new link prior to the position specified in "where". More...
 
int which (node *to_find) const
 locates the index where "to_find" lives in our list of links. More...
 

Static Public Member Functions

static bool has_cycle (singly_linked_list *check)
 returns true if this list has a cycle in it. More...
 

Static Public Attributes

static const int NEXT_NODE = 0
 

Detailed Description

Implements a singly-linked list structure.

Definition at line 23 of file singly_linked_list.h.

Constructor & Destructor Documentation

◆ singly_linked_list()

nodes::singly_linked_list::singly_linked_list ( )
inline

Definition at line 26 of file singly_linked_list.h.

◆ ~singly_linked_list()

nodes::singly_linked_list::~singly_linked_list ( )
inline

Definition at line 29 of file singly_linked_list.h.

Member Function Documentation

◆ elements()

int nodes::singly_linked_list::elements ( ) const

returns the number of items currently in the list, including this node.

this is a costly operation.

◆ has_cycle()

static bool nodes::singly_linked_list::has_cycle ( singly_linked_list check)
inlinestatic

returns true if this list has a cycle in it.

Definition at line 43 of file singly_linked_list.h.

References next(), and NULL_POINTER.

◆ next()

singly_linked_list* nodes::singly_linked_list::next ( )
inline

Definition at line 38 of file singly_linked_list.h.

References nodes::node::get_link(), and NEXT_NODE.

Referenced by has_cycle().

◆ set_next()

void nodes::singly_linked_list::set_next ( singly_linked_list new_next)
inline

Definition at line 40 of file singly_linked_list.h.

References NEXT_NODE, and nodes::node::set_link().

Member Data Documentation

◆ NEXT_NODE

const int nodes::singly_linked_list::NEXT_NODE = 0
static

Definition at line 32 of file singly_linked_list.h.

Referenced by next(), and set_next().


The documentation for this class was generated from the following file: