All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.squarespace.cldrengine.internal.KeyIndex Maven / Gradle / Ivy

The newest version!
package com.squarespace.cldrengine.internal;

import java.util.HashMap;
import java.util.Map;

public class KeyIndex {

  private final T[] elements;
  private final Map map;
  public final int size;

  public KeyIndex(T[] elements) {
    this.elements = elements;
    this.size = elements.length;
    this.map = new HashMap<>();
    for (int i = 0; i < this.size; i++) {
      this.map.put(elements[i], i);
    }
  }

  public int get(T key) {
    Integer i = this.map.get(key);
    return i == null ? -1 : i;
  }

  public T[] keys() {
    return this.elements;
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy