ultimatepp/bazaar/ADT/ADT.cpp
novo 40f507ed4d Added bazaar/ADT/List.h.
git-svn-id: svn://ultimatepp.org/upp/trunk@6254 f0d560ea-af0d-0410-9eb7-867de7ffcac7
2013-08-23 03:49:53 +00:00

60 lines
1.2 KiB
C++

// vi: noexpandtab:tabstop=4
#include <Core/Core.h>
#include "ADT.h"
using namespace Upp;
#if 0
CONSOLE_APP_MAIN
{
// SList tests.
{
using ADT::SListNode;
using ADT::SList;
struct Node : public SListNode<Node> {
Node(int i) : i(i) {}
const int i;
};
typedef SList<Node> List;
Node n0(0), n1(1), n2(2), n3(3), n4(4), n5(5);
List list;
list.PushFront(&n0).PushFront(&n1).PushFront(&n2).PushFront(&n3).PushFront(&n4);
for (SList<Node>::ForwardRange r = list.ForwardR(); !r.IsEmpty(); r.PopFront())
r.Front();
for (SList<Node>::ForwardRange r = list.ForwardR(); !r.IsEmpty(); r.PopFront())
Cout() << r.Front().i << " ";
Cout() << EOL;
}
// DList tests.
{
using ADT::DListNode;
using ADT::DList;
struct Node : public DListNode<Node>
{
Node(int i) : i(i) {}
const int i;
};
typedef DList<Node> List;
Node n0(0), n1(1), n2(2), n3(3), n4(4), n5(5);
List list;
list << n0 << n1 << n2 << n3 << n4;
ASSERT(list.GetLast() == &n4);
for (DList<Node>::ForwardRange r = list.ForwardR(); !r.IsEmpty(); r.PopFront())
r.Front();
n1.ReplaceThisWith(&n5);
n0.RemoveThis();
}
}
#endif