linkedlist.h
// Copyright (c) 2003 David Muse
// See the COPYING file for more information.
#ifndef RUDIMENTS_LINKEDLIST_H
#define RUDIMENTS_LINKEDLIST_H
#include <rudiments/private/linkedlistincludes.h>
template <class valuetype>
class linkedlistnode {
public:
linkedlistnode(valuetype value);
virtual ~linkedlistnode();
void setValue(valuetype value);
valuetype getValue() const;
int32_t compare(valuetype value) const;
void setPrevious(linkedlistnode<valuetype> *previous);
void setNext(linkedlistnode<valuetype> *next);
linkedlistnode<valuetype> *getPrevious();
linkedlistnode<valuetype> *getNext();
void print() const;
#include <rudiments/private/linkedlistnode.h>
};
template < class valuetype >
class linkedlist {
public:
linkedlist();
virtual ~linkedlist();
void append(valuetype value);
void append(linkedlistnode<valuetype> *node);
bool insert(uint64_t index, valuetype value);
bool insert(uint64_t index, linkedlistnode<valuetype> *node);
bool removeByIndex(uint64_t index);
bool removeByValue(valuetype value);
bool removeAllByValue(valuetype value);
bool removeNode(linkedlistnode<valuetype> *node);
bool setValueByIndex(uint64_t index, valuetype value);
bool getValueByIndex(uint64_t index, valuetype *value);
uint64_t getLength() const;
linkedlistnode<valuetype> *getFirstNode();
linkedlistnode<valuetype> *getLastNode();
linkedlistnode<valuetype>
*getNodeByIndex(uint64_t index);
linkedlistnode<valuetype>
*getNodeByValue(valuetype value);
linkedlistnode<valuetype>
*getNodeByValue(linkedlistnode<valuetype> *startnode,
valuetype value);
void clear();
void print() const;
#include <rudiments/private/linkedlist.h>
};
// ideally I'd use typdefs for these but older compilers can't handle them
#define stringlistnode linkedlistnode< char * >
#define stringlist linkedlist< char * >
#define conststringlistnode linkedlistnode< const char * >
#define conststringlist linkedlist< const char * >
#include <rudiments/private/linkedlistinlines.h>
#endif