Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
StackAsNodeStack |
|
| 0.0;0 |
1 | /* | |
2 | This file is part of Combean. | |
3 | ||
4 | Combean is free software; you can redistribute it and/or modify | |
5 | it under the terms of the GNU General Public License as published by | |
6 | the Free Software Foundation; either version 2 of the License, or | |
7 | (at your option) any later version. | |
8 | ||
9 | Combean is distributed in the hope that it will be useful, | |
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | GNU General Public License for more details. | |
13 | ||
14 | You should have received a copy of the GNU General Public License | |
15 | along with Combean; if not, write to the Free Software | |
16 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
17 | */ | |
18 | /* | |
19 | * Created on 20.02.2005 | |
20 | * | |
21 | */ | |
22 | package net.sourceforge.combean.graph.containers; | |
23 | ||
24 | import java.util.Stack; | |
25 | ||
26 | import net.sourceforge.combean.graph.iterators.IteratorAsNodeIterator; | |
27 | import net.sourceforge.combean.interfaces.graph.Node; | |
28 | import net.sourceforge.combean.interfaces.graph.NodeIterator; | |
29 | import net.sourceforge.combean.interfaces.graph.containers.NodeStack; | |
30 | ||
31 | /** | |
32 | * Uses a java.util.Stack to implement a NodeStack. | |
33 | * | |
34 | * @author schickin | |
35 | * | |
36 | */ | |
37 | public class StackAsNodeStack implements NodeStack { | |
38 | ||
39 | 33 | private Stack<Node> stack = null; |
40 | ||
41 | /** | |
42 | * constructor | |
43 | */ | |
44 | public StackAsNodeStack() { | |
45 | 27 | super(); |
46 | 27 | this.stack = new Stack<Node>(); |
47 | 27 | } |
48 | ||
49 | /** | |
50 | * Use a Stack as a NodeStack. | |
51 | * | |
52 | * @param stack the Stack to be wrapped. | |
53 | */ | |
54 | public StackAsNodeStack(Stack<Node> stack) { | |
55 | 6 | super(); |
56 | 6 | this.stack = stack; |
57 | 6 | } |
58 | ||
59 | /* (non-Javadoc) | |
60 | * @see net.sourceforge.combean.interfaces.graph.containers.NodeStack#peek() | |
61 | */ | |
62 | public Node peek() { | |
63 | 15 | return this.stack.peek(); |
64 | } | |
65 | ||
66 | /* (non-Javadoc) | |
67 | * @see net.sourceforge.combean.interfaces.graph.containers.NodeStack#pop() | |
68 | */ | |
69 | public Node pop() { | |
70 | 108 | return this.stack.pop(); |
71 | } | |
72 | ||
73 | /* (non-Javadoc) | |
74 | * @see net.sourceforge.combean.interfaces.graph.containers.NodeStack#push(net.sourceforge.combean.interfaces.graph.Node) | |
75 | */ | |
76 | public Node push(Node v) { | |
77 | 183 | return this.stack.push(v); |
78 | } | |
79 | ||
80 | /* (non-Javadoc) | |
81 | * @see net.sourceforge.combean.interfaces.graph.containers.FixedNodeCollection#isEmpty() | |
82 | */ | |
83 | public boolean isEmpty() { | |
84 | 27 | return this.stack.empty(); |
85 | } | |
86 | ||
87 | /* (non-Javadoc) | |
88 | * @see net.sourceforge.combean.interfaces.graph.containers.FixedNodeCollection#iterator() | |
89 | */ | |
90 | public NodeIterator iterator() { | |
91 | 0 | return new IteratorAsNodeIterator(this.stack.iterator()); |
92 | } | |
93 | ||
94 | /** | |
95 | * @return Returns the stack. | |
96 | */ | |
97 | public Stack<Node> getStack() { | |
98 | 12 | return this.stack; |
99 | } | |
100 | } |