KickJava   Java API By Example, From Geeks To Geeks.

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


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: DxListBag.java,v 1.6 2000/10/28 16:55:14 daniela Exp $
8

9 package org.ozoneDB.DxLib;
10
11
12 public class DxListBag extends DxAbstractBag implements DxListCollection {
13     
14     final static long serialVersionUID = 1L;
15     
16     protected transient DxListNode start;
17     protected transient DxListNode top;
18     protected transient int itemCount = 0;
19     
20     
21     /**
22      */

23     public DxListBag() {
24         start = new DxListNode();
25         top = new DxListNode();
26         start.storeBehind( top );
27     }
28     
29     
30     /**
31      */

32     public synchronized boolean add( Object JavaDoc obj ) {
33         return addBack( obj );
34     }
35     
36     
37     /**
38      */

39     public synchronized boolean addFront( Object JavaDoc obj ) {
40         DxListNode node = new DxListNode( obj );
41         start.storeBehind( node );
42         itemCount++;
43         return true;
44     }
45     
46     
47     /**
48      */

49     public synchronized boolean addBack( Object JavaDoc obj ) {
50         DxListNode node = new DxListNode( obj );
51         top.storeInfront( node );
52         itemCount++;
53         return true;
54     }
55     
56     
57     /**
58      */

59     public DxIterator iterator() {
60         return new DxListIterator( this );
61     }
62     
63     
64     /**
65      */

66     public int count() {
67         return itemCount;
68     }
69     
70     
71     /**
72      */

73     public boolean isEmpty() {
74         return start.next() == top;
75     }
76     
77     
78     /**
79      */

80     public synchronized void clear() {
81         start = new DxListNode();
82         top = new DxListNode();
83         start.storeBehind( top );
84         itemCount = 0;
85     }
86     
87     
88     /**
89      */

90     public DxListNode head() {
91         return start;
92     }
93     
94     
95     /**
96      */

97     public DxListNode tail() {
98         return top;
99     }
100     
101     
102     /**
103      */

104     public void decCounter() {
105         itemCount--;
106     }
107     
108 }
109
Popular Tags