-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathpllist.h
82 lines (64 loc) · 2.79 KB
/
pllist.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
//
// Copyright (c) 1994, 1995, 2006 by Mike Romberg ( [email protected] )
//
// This file may be distributed under terms of the GPL
//
#ifndef _pllist_h
#define _pllist_h
#include "llist.h"
//-------------------------------------------------------------------------
//
// Pointer Linked list. T is some pointer type.
//
//-------------------------------------------------------------------------
template <class T>
class PLList : public LList
{
public:
PLList(void) : LList(){}
// PLList(int(*cmp_fun)(T data, K key)) : LList(cmp_fun){}
int push(const T data) { return LList::push((void *)data); }
T pop(void) { return (T)LList::pop(); }
int enqueue(const T data) { return LList::enqueue((void *)data); }
T dequeue(void) { return (T)LList::dequeue(); }
// int insert(const T data, const K key)
// { return LList::insert((void *)data, (void *)key); }
// T find(const K key) { return (T)LList::find((void *)key); }
// T removematch(const K key)
// { return (T)LList::removematch((void *)key); }
int putontop(const T data) { return LList::putontop((void *)data); }
void remove(const T data) { LList::remove((void *)data); }
T findn(int n) { return (T)LList::findn(n); }
T operator[](int n) { return findn(n); }
int index(const T data) { return LList::index((void *)data); }
T findc(int which = 0) { return (T)LList::findc(which); }
};
//-------------------------------------------------------------------------
//
// Sorted Pointer List. T is some type of pointer and K is a pointer to
// the key type for this list.
//
//-------------------------------------------------------------------------
template <class T, class K>
class PSLList : public LList
{
public:
PSLList(void) : LList(){}
PSLList(int(*cmp_fun)(T data, K key)) : LList(cmp_fun){}
int push(const T data) { return LList::push((void *)data); }
T pop(void) { return (T)LList::pop(); }
int enqueue(const T data) { return LList::enqueue((void *)data); }
T dequeue(void) { return (T)LList::dequeue(); }
int insert(const T data, const K key)
{ return LList::insert((void *)data, (void *)key); }
T find(const K key) { return (T)LList::find((void *)key); }
T removematch(const K key)
{ return (T)LList::removematch((void *)key); }
int putontop(const T data) { return LList::putontop((void *)data); }
void remove(const T data) { LList::remove((void *)data); }
T findn(int n) { return (T)LList::findn(n); }
T operator[](int n) { return findn(n); }
int index(const T data) { return LList::index((void *)data); }
T findc(int which = 0) { return (T)LList::findc(which); }
};
#endif