📄 sortedlinkedlistunique.h
字号:
/* $Id: SortedLinkedListUnique.h,v 1.2 1997/02/02 01:31:04 matt Exp $ Sorted linked lists with all unique items (no duplicatates). Requires == and < operators for items. (c) Oct 1995 Matt Phillips. */#ifndef _SLLISTU_H#define _SLLISTU_H#include "SortedLinkedList.h"template <class T, class E>class SortedLinkedListUniqueImp : public SortedLinkedListImp<T, E>{public: SortedLinkedListUniqueImp () {} SortedLinkedListUniqueImp (const SortedLinkedListUniqueImp<T, E> &l) : SortedLinkedListImp<T, E> (l) {} virtual const char *name () const {return "SortedListUnique";} virtual void add (T &i);};template <class T, class E>void SortedLinkedListUniqueImp<T, E>::add (T &i){ E *prev, *c; // search list for (prev = 0, c = head; c && c->ref () < i; prev = c, c = c->next); // if whole list was searched, or the item after i is not equal to i if (!c || !(c->ref () == i)) { if (prev) { prev->next = new E (i, prev->next); } else { head = new E (i, head); } _nItems++; } else if (E::isOwner ()) { delete &i; }}#define TypeDSortedLinkedListUnique(T) SortedLinkedListUniqueImp<T, DLinkedItem<T> >#define TypeISortedLinkedListUnique(T) SortedLinkedListUniqueImp<T, ILinkedItem<T, 0> >#define TypeIOSortedLinkedListUnique(T) SortedLinkedListUniqueImp<T, ILinkedItem<T, 1> >#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -