|
|||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
BooleanStack.java | 0% | 0% | 0% | 0% |
|
1 | /* | |
2 | * :tabSize=8:indentSize=4:noTabs=true:maxLineLen=0: | |
3 | * | |
4 | * Copyright (c) 2001 Dirk Moebius. | |
5 | * | |
6 | * BooleanStack.java - a wrapper class for a typesafe stack. | |
7 | * | |
8 | * Part of the C++ to Java port of AStyle, maintained by | |
9 | * Dirk Moebius (dmoebius@gmx.net). | |
10 | * | |
11 | * The "Artistic Style" project, including all files needed to compile it, | |
12 | * is free software; you can redistribute it and/or use it and/or modify it | |
13 | * under the terms of EITHER the "Artistic License" OR | |
14 | * the GNU Library General Public License as published by the Free Software | |
15 | * Foundation; either version 2 of the License, or (at your option) any later | |
16 | * version. | |
17 | * | |
18 | * This program is distributed in the hope that it will be useful, | |
19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |
21 | * | |
22 | * You should have received a copy of EITHER the "Artistic License" or | |
23 | * the GNU Library General Public License along with this program. | |
24 | */ | |
25 | ||
26 | ||
27 | package net.sourceforge.astyleclipse.astyle.util; | |
28 | ||
29 | ||
30 | import java.util.Stack; | |
31 | ||
32 | ||
33 | // FIXME: this class could more efficiently be implemented as array of boolean | |
34 | // or bitset | |
35 | ||
36 | /** | |
37 | * This is a stack of booleans. | |
38 | */ | |
39 | public class BooleanStack extends Stack { | |
40 | ||
41 | 0 | public BooleanStack() { |
42 | 0 | super(); |
43 | } | |
44 | ||
45 | ||
46 | /** | |
47 | * same as push() | |
48 | * @see java.util.Stack#push | |
49 | */ | |
50 | 0 | public void push_back(boolean b) { |
51 | 0 | super.push(new Boolean(b)); |
52 | } | |
53 | ||
54 | ||
55 | /** | |
56 | * same as pop() | |
57 | * @see java.util.Stack#pop | |
58 | */ | |
59 | 0 | public boolean pop_back() { |
60 | 0 | if (empty()) |
61 | 0 | throw new Error("empty stack"); |
62 | 0 | return ((Boolean)super.pop()).booleanValue(); |
63 | } | |
64 | ||
65 | ||
66 | /** | |
67 | * same as peek() | |
68 | * @see java.util.Stack#peek | |
69 | */ | |
70 | 0 | public boolean back() { |
71 | 0 | if (empty()) |
72 | 0 | throw new Error("empty stack"); |
73 | 0 | return ((Boolean)super.peek()).booleanValue(); |
74 | } | |
75 | ||
76 | ||
77 | 0 | public BooleanStack getClone() { |
78 | 0 | return (BooleanStack) clone(); |
79 | } | |
80 | ||
81 | } | |
82 |
|