KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ozoneDB > DxLib > DxListDeque


1 // You can redistribute this software and/or modify it under the terms of
2
// the Ozone Library License version 1 published by ozone-db.org.
3
//
4
// The original code and portions created by SMB are
5
// Copyright (C) 1997-@year@ by SMB GmbH. All rights reserved.
6
//
7
// $Id: DxListDeque.java,v 1.6 2000/10/28 16:55:14 daniela Exp $
8

9 package org.ozoneDB.DxLib;
10
11 /**
12  *
13  *
14  * @author <a HREF="http://www.softwarebuero.de/">SMB</a>
15  * @version $Revision: 1.6 $Date: 2000/10/28 16:55:14 $
16  */

17 public class DxListDeque extends DxListBag implements DxDeque {
18     
19     final static long serialVersionUID = 1L;
20     
21     
22     /**
23      */

24     public DxListDeque() {
25     }
26     
27     
28     /**
29      */

30     public Object JavaDoc peek() {
31         return peekBottom();
32     }
33     
34     
35     /**
36      */

37     public Object JavaDoc peekTop() {
38         //if the deque is empty, this return null
39
return top.prev().data();
40     }
41     
42     
43     /**
44      */

45     public Object JavaDoc peekBottom() {
46         //if the deque is empty, this return null
47
return start.next().data();
48     }
49     
50     
51     /**
52      */

53     public synchronized void push( Object JavaDoc obj ) {
54         pushBottom( obj );
55     }
56     
57     
58     /**
59      */

60     public synchronized void pushTop( Object JavaDoc obj ) {
61         top.storeInfront( new DxListNode( obj ) );
62         itemCount++;
63     }
64     
65     
66     /**
67      */

68     public synchronized void pushBottom( Object JavaDoc obj ) {
69         start.storeBehind( new DxListNode( obj ) );
70         itemCount++;
71     }
72     
73     
74     /**
75      */

76     public Object JavaDoc pop() {
77         return popBottom();
78     }
79     
80     
81     /**
82      */

83     public Object JavaDoc popTop() {
84         Object JavaDoc answer = top.prev().data();
85         if (answer != null) {
86             top.prev().remove();
87             itemCount--;
88         }
89         return answer;
90     }
91     
92     
93     /**
94      */

95     public Object JavaDoc popBottom() {
96         Object JavaDoc answer = start.next().data();
97         if (answer != null) {
98             start.next().remove();
99             itemCount--;
100         }
101         return answer;
102     }
103 }
104
Popular Tags