|
|||||||||||||||||||
| Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
| IntegerStack.java | 0% | 0% | 0% | 0% |
|
||||||||||||||
| 1 | /* | |
| 2 | * :tabSize=8:indentSize=4:noTabs=true:maxLineLen=0: | |
| 3 | * | |
| 4 | * Copyright (c) 2001 Dirk Moebius. | |
| 5 | * | |
| 6 | * IntegerStack.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 | /** | |
| 34 | * This is a stack of integers. | |
| 35 | */ | |
| 36 | public class IntegerStack extends Stack { | |
| 37 | ||
| 38 | 0 | public IntegerStack() { |
| 39 | 0 | super(); |
| 40 | } | |
| 41 | ||
| 42 | ||
| 43 | /** | |
| 44 | * same as push() | |
| 45 | * @see java.util.Stack#push | |
| 46 | */ | |
| 47 | 0 | public void push_back(int i) { |
| 48 | 0 | super.push(new Integer(i)); |
| 49 | } | |
| 50 | ||
| 51 | ||
| 52 | /** | |
| 53 | * same as pop() | |
| 54 | * @see java.util.Stack#pop | |
| 55 | */ | |
| 56 | 0 | public int pop_back() { |
| 57 | 0 | if (empty()) |
| 58 | 0 | throw new Error("empty stack"); |
| 59 | 0 | return ((Integer)super.pop()).intValue(); |
| 60 | } | |
| 61 | ||
| 62 | ||
| 63 | /** | |
| 64 | * same as peek() | |
| 65 | * @see java.util.Stack#peek | |
| 66 | */ | |
| 67 | 0 | public int back() { |
| 68 | 0 | if (empty()) |
| 69 | 0 | throw new Error("empty stack"); |
| 70 | 0 | return ((Integer)super.peek()).intValue(); |
| 71 | } | |
| 72 | ||
| 73 | ||
| 74 | /** | |
| 75 | * same as elementAt() | |
| 76 | * @see java.util.Vector#elementAt | |
| 77 | */ | |
| 78 | 0 | public int at(int i) { |
| 79 | 0 | return ((Integer)super.elementAt(i)).intValue(); |
| 80 | } | |
| 81 | ||
| 82 | ||
| 83 | /** | |
| 84 | * increase the value stored at back() | |
| 85 | */ | |
| 86 | 0 | public void incBack() { |
| 87 | 0 | int v = back(); |
| 88 | 0 | elementData[elementCount - 1] = new Integer(v + 1); |
| 89 | } | |
| 90 | ||
| 91 | ||
| 92 | /** | |
| 93 | * decrease the value stored at back() | |
| 94 | */ | |
| 95 | 0 | public void decBack() { |
| 96 | 0 | int v = back(); |
| 97 | 0 | elementData[elementCount - 1] = new Integer(v - 1); |
| 98 | } | |
| 99 | ||
| 100 | ||
| 101 | 0 | public IntegerStack getClone() { |
| 102 | 0 | return (IntegerStack) clone(); |
| 103 | } | |
| 104 | ||
| 105 | } | |
| 106 |
|
||||||||||