forked from uncrustify/uncrustify
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathChunkStack.h
More file actions
80 lines (59 loc) · 1.12 KB
/
ChunkStack.h
File metadata and controls
80 lines (59 loc) · 1.12 KB
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
/**
* @file ChunkStack.h
* Manages a simple stack of chunks
*
* @author Ben Gardner
* @license GPL v2+
*/
#ifndef CHUNKSTACK_H_INCLUDED
#define CHUNKSTACK_H_INCLUDED
#include "uncrustify_types.h"
class ChunkStack
{
public:
struct Entry
{
int m_seqnum;
chunk_t *m_pc;
};
protected:
Entry *m_cse; // the array of entries
int m_size; // entries allocated
int m_len; // entries used
int m_seqnum; // current seq num
public:
ChunkStack()
{
Init();
}
ChunkStack(const ChunkStack& cs);
~ChunkStack();
void Set(const ChunkStack& cs);
void Push(chunk_t *pc)
{
Push(pc, ++m_seqnum);
}
bool Empty() const
{
return(m_len == 0);
}
int Len() const
{
return(m_len);
}
const Entry *Top() const;
const Entry *Get(int idx) const;
chunk_t *GetChunk(int idx) const;
chunk_t *Pop();
void Push(chunk_t *pc, int seqnum);
void Reset()
{
m_len = 0;
}
void Zap(int idx);
void Collapse();
protected:
void Init();
void Resize(int newsize);
};
#endif /* CHUNKSTACK_H_INCLUDED */