linkedlist_internals.hpp File Reference

#include "Node.hpp"
#include "Cell.hpp"
#include <string>
#include <iostream>

Go to the source code of this file.

Functions

Cellmake_int (int i)
 Make an int cell.
Cellmake_double (double d)
 Make a double cell.
Cellmake_symbol (const char *s)
 Make a symbol cell.
Nodemake_node (Cell *my_elem, Node *my_next)
 Make a linked list node.
bool intp (const Cell *c)
 Check if d points to an int node.
bool doublep (const Cell *c)
 Check if d points to a double node.
bool symbolp (const Cell *c)
 Check if d points to a symbol node.
int get_int (const Cell *c)
 Accessor (error if d is not an int node).
double get_double (const Cell *c)
 Accessor (error if d is not a double node).
char * get_symbol (const Cell *c)
 Retrieve the symbol name as a string (error if d is not a symbol node).
Cellget_elem (const Node *n)
 Accessor.
Nodeget_next (const Node *n)
 Accessor.
std::ostream & operator<< (std::ostream &os, const Node &n)
 Print the linked list rooted at n in parentheses.


Detailed Description

Encapsulates an abstract interface layer for a cons list ADT, without using member functions. Makes no assumptions about what kind of concrete type Cell will be defined to be.

Function Documentation

bool doublep ( const Cell c  )  [inline]

Check if d points to a double node.

Returns:
True iff d points to a double node.

double get_double ( const Cell c  )  [inline]

Accessor (error if d is not a double node).

Returns:
The value in the double node pointed to by c.

Cell* get_elem ( const Node n  )  [inline]

Accessor.

Returns:
The elem pointer in the linked list node pointed to by c.

int get_int ( const Cell c  )  [inline]

Accessor (error if d is not an int node).

Returns:
The value in the int node pointed to by c.

Node* get_next ( const Node n  )  [inline]

Accessor.

Returns:
The next pointer in the linked list node pointed to by c.

char* get_symbol ( const Cell c  )  [inline]

Retrieve the symbol name as a string (error if d is not a symbol node).

Returns:
The symbol name in the symbol node pointed to by c.

bool intp ( const Cell c  )  [inline]

Check if d points to an int node.

Returns:
True iff d points to an int node.

Cell* make_double ( double  d  )  [inline]

Make a double cell.

Parameters:
d The initial double value to be stored in the new cell.

Cell* make_int ( int  i  )  [inline]

Make an int cell.

Parameters:
i The initial int value to be stored in the new cell.

Referenced by main().

Node* make_node ( Cell my_elem,
Node my_next 
) [inline]

Make a linked list node.

Parameters:
my_elem Pointer to the element to be held by this node.
my_next Pointer to the next node.

Referenced by main().

Cell* make_symbol ( const char *  s  )  [inline]

Make a symbol cell.

Parameters:
s The initial symbol name to be stored in the new cell.

std::ostream& operator<< ( std::ostream &  os,
const Node n 
) [inline]

Print the linked list rooted at n in parentheses.

Parameters:
os The output stream to print to.
n The root node of the linked list to be printed.

bool symbolp ( const Cell c  )  [inline]

Check if d points to a symbol node.

Returns:
True iff d points to a symbol node.


Generated on Tue Sep 16 10:30:40 2014 for COMP2012H by  doxygen 1.5.8