132
|
1 /*
|
|
2 File: Cell.d
|
|
3
|
|
4 Originally written by Doug Lea and released into the public domain.
|
|
5 Thanks for the assistance and support of Sun Microsystems Labs, Agorics
|
|
6 Inc, Loral, and everyone contributing, testing, and using this code.
|
|
7
|
|
8 History:
|
|
9 Date Who What
|
|
10 24Sep95 dl@cs.oswego.edu Create from tango.util.collection.d working file
|
|
11 9Apr97 dl made Serializable
|
|
12
|
|
13 */
|
|
14
|
|
15
|
|
16 module tango.util.collection.impl.Cell;
|
|
17
|
|
18 /**
|
|
19 *
|
|
20 *
|
|
21 * Cell is the base of a bunch of implementation classes
|
|
22 * for lists and the like.
|
|
23 * The base version just holds an Object as its element value
|
|
24 *
|
|
25 author: Doug Lea
|
|
26 * @version 0.93
|
|
27 *
|
|
28 * <P> For an introduction to this package see <A HREF="index.html"> Overview </A>.
|
|
29 **/
|
|
30
|
|
31 public class Cell (T)
|
|
32 {
|
|
33 // instance variables
|
|
34 private T element_;
|
|
35
|
|
36 /**
|
|
37 * Make a cell with element value v
|
|
38 **/
|
|
39
|
|
40 public this (T v)
|
|
41 {
|
|
42 element_ = v;
|
|
43 }
|
|
44
|
|
45 /**
|
|
46 * Make A cell with null element value
|
|
47 **/
|
|
48
|
|
49 public this ()
|
|
50 {
|
|
51 // element_ = null;
|
|
52 }
|
|
53
|
|
54 /**
|
|
55 * return the element value
|
|
56 **/
|
|
57
|
|
58 public final T element()
|
|
59 {
|
|
60 return element_;
|
|
61 }
|
|
62
|
|
63 /**
|
|
64 * set the element value
|
|
65 **/
|
|
66
|
|
67 public final void element (T v)
|
|
68 {
|
|
69 element_ = v;
|
|
70 }
|
|
71
|
|
72 public final int elementHash ()
|
|
73 {
|
|
74 return typeid(T).getHash(&element_);
|
|
75 }
|
|
76
|
|
77 protected Cell duplicate()
|
|
78 {
|
|
79 return new Cell (element_);
|
|
80 }
|
|
81 }
|