01: // You can redistribute this software and/or modify it under the terms of
02: // the Ozone Library License version 1 published by ozone-db.org.
03: //
04: // The original code and portions created by SMB are
05: // Copyright (C) 1997-@year@ by SMB GmbH. All rights reserved.
06: //
07: // $Id: DxArrayDeque.java,v 1.1 2001/12/18 10:31:30 per_nyfelt Exp $
08:
09: package org.ozoneDB.DxLib;
10:
11: /**
12: * @author <a href="http://www.softwarebuero.de/">SMB</a>
13: * @version $Revision: 1.1 $Date: 2001/12/18 10:31:30 $
14: */
15: public class DxArrayDeque extends DxArrayBag implements DxDeque {
16:
17: final static long serialVersionUID = 1L;
18:
19: public DxArrayDeque() {
20: }
21:
22: public DxArrayDeque(int initSpace) {
23: super (initSpace);
24: }
25:
26: public Object peek() {
27: return peekBottom();
28: }
29:
30: public Object peekTop() {
31: return isEmpty() ? null : elementAtIndex(size() - 1);
32: }
33:
34: public Object peekBottom() {
35: return isEmpty() ? null : elementAtIndex(0);
36: }
37:
38: public synchronized void push(Object obj) {
39: pushTop(obj);
40: }
41:
42: public synchronized void pushTop(Object obj) {
43: insertAtIndex(obj, size());
44: }
45:
46: public synchronized void pushBottom(Object obj) {
47: insertAtIndex(obj, 0);
48: }
49:
50: public Object pop() {
51: return popTop();
52: }
53:
54: public Object popTop() {
55: return isEmpty() ? null : deleteAtIndex(size() - 1);
56: }
57:
58: public Object popBottom() {
59: return isEmpty() ? null : deleteAtIndex(0);
60: }
61:
62: }
|