1 package org.catacomb.numeric.data;
2
3 import org.catacomb.interlish.structure.TreeNode;
4
5
6 public class DVector implements TreeNode, NumVector {
7
8 Object parent;
9
10 String id;
11
12 int ndat;
13 double[] dat;
14
15
16 public DVector(Object par, String s) {
17 parent = par;
18 id = s;
19 ndat = 0;
20 dat = new double[10];
21
22 }
23
24
25
26
27
28
29
30 public String toString() {
31 return id;
32 }
33
34
35 public int getNPoint() {
36 return ndat;
37 }
38
39 public double[] getData() {
40 return dat;
41 }
42
43 public void add(double d) {
44 if (ndat == dat.length) {
45 double[] da = new double[2 * ndat];
46 for (int i = 0; i < ndat; i++) {
47 da[i] = dat[i];
48 }
49 dat = da;
50 }
51 dat[ndat++] = d;
52 }
53
54 public Object getParent() {
55 return parent;
56 }
57
58 public int getChildCount() {
59 return 0;
60 }
61
62 public Object getChild(int index) {
63 return null;
64 }
65
66 public int getIndexOfChild(Object child) {
67 return 0;
68 }
69
70 public boolean isLeaf() {
71 return true;
72 }
73
74 public String getUnit() {
75 return "err";
76 }
77
78 public String getName() {
79 return id;
80 }
81
82 public String getLabel() {
83 return id;
84 }
85
86
87 }