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: DxListBag.java,v 1.1 2001/12/18 10:31:30 per_nyfelt Exp $
08:
09: package org.ozoneDB.DxLib;
10:
11: public class DxListBag extends DxAbstractBag implements
12: 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: public DxListBag() {
23: start = new DxListNode();
24: top = new DxListNode();
25: start.storeBehind(top);
26: }
27:
28: /**
29: */
30: public synchronized boolean add(Object obj) {
31: return addBack(obj);
32: }
33:
34: /**
35: */
36: public synchronized boolean addFront(Object obj) {
37: DxListNode node = new DxListNode(obj);
38: start.storeBehind(node);
39: itemCount++;
40: return true;
41: }
42:
43: /**
44: */
45: public synchronized boolean addBack(Object obj) {
46: DxListNode node = new DxListNode(obj);
47: top.storeInfront(node);
48: itemCount++;
49: return true;
50: }
51:
52: /**
53: */
54: public DxIterator iterator() {
55: return new DxListIterator(this );
56: }
57:
58: /**
59: */
60: public int count() {
61: return itemCount;
62: }
63:
64: /**
65: */
66: public boolean isEmpty() {
67: return start.next() == top;
68: }
69:
70: /**
71: */
72: public synchronized void clear() {
73: start = new DxListNode();
74: top = new DxListNode();
75: start.storeBehind(top);
76: itemCount = 0;
77: }
78:
79: /**
80: */
81: public DxListNode head() {
82: return start;
83: }
84:
85: /**
86: */
87: public DxListNode tail() {
88: return top;
89: }
90:
91: /**
92: */
93: public void decCounter() {
94: itemCount--;
95: }
96:
97: }
|