// CIS-62 circularly-linked list

#ifndef _CIS62_CIRCULARLY_LINKED_LIST_INCLUDED_
#define _CIS62_CIRCULARLY_LINKED_LIST_INCLUDED_

// circularly_linked_list.h
#include <cassert>
#include <iostream>
using namespace std;

class Node
{
    friend void print_list( Node const& head );
private:
    mutable Node* pnext;
public:
    int data;

    // Constructor
    Node( int value = 0 );

    // Copy constructor
    Node( Node const& other );

    // Destructor
    ~Node();

    // Insert other node in front:
    Node& insert( Node& other ) const;

    // Is the node single or linked to some other node?
    bool is_single() const;

    // Calculate the distance between the nodes measured in hops between the nodes: 
    int distance( Node const& other ) const;

    // Return number of nodes in the list:
    size_t size() const;

    // Remove the node from the list:
    bool remove( Node& other );
};

void print_list( Node const& head );

#endif // _CIS62_CIRCULARLY_LINKED_LIST_INCLUDED_

