Edinburgh Speech Tools
2.4-release
All
Classes
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Pages
EST_TDeque.h
1
/************************************************************************/
2
/* */
3
/* Centre for Speech Technology Research */
4
/* University of Edinburgh, UK */
5
/* Copyright (c) 1996,1997 */
6
/* All Rights Reserved. */
7
/* */
8
/* Permission is hereby granted, free of charge, to use and distribute */
9
/* this software and its documentation without restriction, including */
10
/* without limitation the rights to use, copy, modify, merge, publish, */
11
/* distribute, sublicense, and/or sell copies of this work, and to */
12
/* permit persons to whom this work is furnished to do so, subject to */
13
/* the following conditions: */
14
/* 1. The code must retain the above copyright notice, this list of */
15
/* conditions and the following disclaimer. */
16
/* 2. Any modifications must be clearly marked as such. */
17
/* 3. Original authors' names are not deleted. */
18
/* 4. The authors' names are not used to endorse or promote products */
19
/* derived from this software without specific prior written */
20
/* permission. */
21
/* */
22
/* THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK */
23
/* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */
24
/* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */
25
/* SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE */
26
/* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */
27
/* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */
28
/* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */
29
/* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */
30
/* THIS SOFTWARE. */
31
/* */
32
/*************************************************************************/
33
34
35
#ifndef __EST_TDEQUE_H__
36
#define __EST_TDEQUE_H__
37
38
#include "EST_TVector.h"
39
#include "instantiate/EST_TDequeI.h"
40
41
/** Double ended queue.
42
*
43
* @author Richard Caley <rjc@cstr.ed.ac.uk>
44
* @version $Id: EST_TDeque.h,v 1.3 2006/07/19 21:52:12 awb Exp $
45
*/
46
47
template
<
class
T>
48
class
EST_TDeque
{
49
private
:
50
EST_TVector<T>
p_vector;
51
int
p_increment;
52
int
p_back;
53
int
p_front;
54
55
// Make the structure bigger.
56
void
expand(
void
);
57
58
public
:
59
EST_TDeque
(
unsigned
int
capacity,
unsigned
int
increment);
60
EST_TDeque
(
unsigned
int
capacity);
61
EST_TDeque
(
void
);
62
63
/// Used to fill empty spaces when possible.
64
static
const
T *
Filler
;
65
66
/// Empty it out.
67
void
clear
(
void
);
68
69
/// Is there anything to get?
70
bool
is_empty
(
void
)
const
;
71
72
/// print picture of state. Mostly useful for debugging.
73
ostream &
print
(ostream &s)
const
;
74
75
/**@name stack
76
*
77
* An interface looking like a stack.
78
*/
79
//@{
80
void
push(T &item);
81
T &pop(
void
);
82
T &nth(
int
i);
83
//@}
84
85
/**@name inverse stack
86
*
87
* The other end as a stack.
88
*/
89
//@{
90
void
back_push(T& item);
91
T &back_pop(
void
);
92
//@}
93
94
/**@name queue
95
*
96
* An interface looking like a queue.
97
*/
98
//@{
99
void
add(T& item) { push(item); }
100
T &next() {
return
back_pop(); }
101
T &last() {
return
pop(); }
102
//@}
103
104
/**@name perl
105
*
106
* For people who think in perl
107
*/
108
//@{
109
void
unshift(T& item) { back_push(item); }
110
T &shift() {
return
back_pop(); }
111
//@}
112
113
friend
ostream& operator << (ostream &st, const EST_TDeque< T > &deq)
114
{
115
return
deq.print(st);
116
}
117
};
118
119
#endif
120
include
EST_TDeque.h
Generated on Wed Dec 24 2014 09:16:35 for Edinburgh Speech Tools by
1.8.3.1