15 package com.cloudera.impala.util;
18 import java.util.ArrayList;
19 import java.util.List;
21 import com.google.common.base.Preconditions;
22 import com.google.common.collect.Maps;
23 import com.google.common.collect.Lists;
34 public class ListMap<T> {
36 private List<T> list_ = Lists.newArrayList();
38 private final Map<T, Integer> map_ = Maps.newHashMap();
40 public List<T>
getList() {
return list_; }
41 public int size() {
return list_.size(); }
46 public T
getEntry(Integer index) {
return list_.get(index); }
53 Integer index = map_.get(t);
57 index = list_.size() - 1;
68 Preconditions.checkState(list_.isEmpty() && map_.isEmpty());
70 Preconditions.checkState(list instanceof ArrayList<?>);
72 for (
int i = 0; i < list_.size(); ++i) {
73 map_.put(list_.get(i), i);
void populate(List< T > list)
T getEntry(Integer index)