Skip to content

Commit 11d45f9

Browse files
committed
remove checks from hash-based accessors, cleanup
1 parent 4876277 commit 11d45f9

1 file changed

Lines changed: 32 additions & 48 deletions

File tree

‎common-tools/clas-utils/src/main/java/org/jlab/utils/groups/IndexedTable.java‎

Lines changed: 32 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -122,10 +122,6 @@ public void setIntValue(Integer value, String item, int... index){
122122
}
123123
}
124124

125-
public void setIntValueByHash(Integer value, int column, long hash) {
126-
this.entries.getItemByHash(hash).setValue(column, value);
127-
}
128-
129125
public void setDoubleValue(Double value, String item, int... index){
130126
if(this.entries.hasItem(index)==false){
131127
if(DEBUG_MODE>0) System.out.println( "[IndexedTable] ---> error.. entry does not exist");
@@ -139,50 +135,6 @@ public void setDoubleValue(Double value, String item, int... index){
139135
}
140136
}
141137

142-
public int getIntValueByHash(int index, long hash) {
143-
if (this.entries.hasItemByHash(hash))
144-
return this.entries.getItemByHash(hash).getValue(index).intValue();
145-
return 0;
146-
}
147-
148-
public double getDoubleValueByHash(int index, long hash) {
149-
if (this.entries.hasItemByHash(hash))
150-
return this.entries.getItemByHash(hash).getValue(index).doubleValue();
151-
return 0;
152-
}
153-
154-
public int getIntValueByHash(String item, long hash) {
155-
if (this.entries.hasItemByHash(hash)) {
156-
if (this.entryMap.containsKey(item)) {
157-
int index = this.entryMap.get(item);
158-
return this.entries.getItemByHash(hash).getValue(index).intValue();
159-
}
160-
}
161-
return 0;
162-
}
163-
164-
public double getDoubleValueByHash(String item, long hash) {
165-
if (this.entries.hasItemByHash(hash)) {
166-
if (this.entryMap.containsKey(item)) {
167-
int index = this.entryMap.get(item);
168-
return this.entries.getItemByHash(hash).getValue(index).doubleValue();
169-
}
170-
}
171-
return 0;
172-
}
173-
174-
public List<Number> getValuesByHash(long hash) {
175-
return this.entries.getItemByHash(hash).entryValues;
176-
}
177-
178-
public List<Integer> getIntegersByHash(long hash) {
179-
return getValuesByHash(hash).stream().map(x -> x.intValue()).collect(Collectors.toList());
180-
}
181-
182-
public List<Double> getDoublesByHash(long hash) {
183-
return getValuesByHash(hash).stream().map(x -> x.doubleValue()).collect(Collectors.toList());
184-
}
185-
186138
public int getIntValue(String item, int... index){
187139
if(this.entries.hasItem(index)==false){
188140
if(DEBUG_MODE>0) System.out.println( "[IndexedTable] ---> error.. entry does not exist");
@@ -211,6 +163,38 @@ public double getDoubleValue(String item, int... index){
211163
return 0;
212164
}
213165

166+
public void setIntValueByHash(Integer value, int column, long hash) {
167+
this.entries.getItemByHash(hash).setValue(column, value);
168+
}
169+
170+
public int getIntValueByHash(int index, long hash) {
171+
return entries.getItemByHash(hash).getValue(index).intValue();
172+
}
173+
174+
public double getDoubleValueByHash(int index, long hash) {
175+
return entries.getItemByHash(hash).getValue(index).doubleValue();
176+
}
177+
178+
public int getIntValueByHash(String item, long hash) {
179+
return entries.getItemByHash(hash).getValue(entryMap.get(item)).intValue();
180+
}
181+
182+
public double getDoubleValueByHash(String item, long hash) {
183+
return entries.getItemByHash(hash).getValue(entryMap.get(item)).doubleValue();
184+
}
185+
186+
public List<Number> getValuesByHash(long hash) {
187+
return this.entries.getItemByHash(hash).entryValues;
188+
}
189+
190+
public List<Integer> getIntegersByHash(long hash) {
191+
return getValuesByHash(hash).stream().map(x -> x.intValue()).collect(Collectors.toList());
192+
}
193+
194+
public List<Double> getDoublesByHash(long hash) {
195+
return getValuesByHash(hash).stream().map(x -> x.doubleValue()).collect(Collectors.toList());
196+
}
197+
214198
public NamedEntry getNamedEntry(int... index) {
215199
return NamedEntry.create(entries.getItem(index), entryNames, index);
216200
}

0 commit comments

Comments
 (0)