22 #include "reference_list.h"
25 class ReferenceListNode {
30 ReferenceListNode(
const Reference &ref) : reference(ref),
next(NULL) {}
34 ReferenceListNode *
next;
37 class ReferenceListHeadNode :
private ReferenceListNode {
41 ReferenceListHeadNode(
const Reference &ref) : ReferenceListNode(ref), refcount(1), length(0) {}
52 ReferenceList::ReferenceList() :
77 ReferenceListHeadNode *tmpHead = list.head;
81 ReferenceListNode *tmpTail = list.tail;
87 void ReferenceList::append(
const Reference& ref)
90 tail = head =
new ReferenceListHeadNode(ref);
92 tail->next =
new ReferenceListNode(ref);
98 int ReferenceList::length()
100 return head ? head->length : 0;
103 ReferenceList::~ReferenceList()
105 if (head != NULL && --(head->refcount) == 0) {
106 ReferenceListNode *
next;
108 for (ReferenceListNode *p = head; p != NULL; p =
next) {
111 delete (ReferenceListHeadNode *)p;
133 ReferenceListIterator::ReferenceListIterator(ReferenceListNode *n) :
140 return node != it.node;
143 const Reference *ReferenceListIterator::operator->()
const
145 return &node->reference;
148 const Reference &ReferenceListIterator::operator++(
int )
An iterator for a ReferenceList.
A list of Reference objects.
Defines a Javascript reference.
const TDEShortcut & next()