EMMA Coverage Report (generated Tue Feb 12 22:23:49 ICT 2008)
[all classes][net.sourceforge.hiveutils.collections.impl]

COVERAGE SUMMARY FOR SOURCE FILE [StackImpl.java]

nameclass, %method, %block, %line, %
StackImpl.java100% (1/1)100% (7/7)100% (53/53)100% (14/14)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class StackImpl100% (1/1)100% (7/7)100% (53/53)100% (14/14)
StackImpl (): void 100% (1/1)100% (8/8)100% (2/2)
checkNotEmpty (): void 100% (1/1)100% (9/9)100% (3/3)
clear (): void 100% (1/1)100% (4/4)100% (2/2)
isEmpty (): boolean 100% (1/1)100% (4/4)100% (1/1)
peek (): Object 100% (1/1)100% (11/11)100% (2/2)
pop (): Object 100% (1/1)100% (11/11)100% (2/2)
push (Object): void 100% (1/1)100% (6/6)100% (2/2)

1//  Copyright 2004-2007 Jean-Francois Poilpret
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14 
15package net.sourceforge.hiveutils.collections.impl;
16 
17import java.util.ArrayList;
18import java.util.EmptyStackException;
19import java.util.List;
20 
21import net.sourceforge.hiveutils.collections.Stack;
22 
23/**
24 * Implementation of <code>Stack</code>, based on <code>ArrayList</code>.
25 *
26 * @author Jean-Francois Poilpret
27 */
28public class StackImpl<T> implements Stack<T>
29{
30        public void                push(T o)
31        {
32                _stack.add(o);
33        }
34        
35        public T        pop()
36        {
37                checkNotEmpty();
38                return _stack.remove(_stack.size() - 1);
39        }
40        
41        public T        peek()
42        {
43                checkNotEmpty();
44                return _stack.get(_stack.size() - 1);
45        }
46        
47        public boolean        isEmpty()
48        {
49                return _stack.isEmpty();
50        }
51        
52        public void                clear()
53        {
54                _stack.clear();
55        }
56        
57        private void        checkNotEmpty()
58        {
59                if (_stack.isEmpty())
60                {
61                        throw new EmptyStackException();
62                }
63        }
64        
65        final private List<T>        _stack = new ArrayList<T>();
66}

[all classes][net.sourceforge.hiveutils.collections.impl]
EMMA 2.0.5312 (C) Vladimir Roubtsov