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

edu.berkeley.nlp.util.AbstractTMap Maven / Gradle / Ivy

Go to download

The Berkeley parser analyzes the grammatical structure of natural language using probabilistic context-free grammars (PCFGs).

The newest version!
package edu.berkeley.nlp.util;

import java.io.*;
import java.util.*;

/**
 * Just a dummy class.
 * TODO: move common functionality here.
 */
public abstract class AbstractTMap implements Serializable {
  protected static final long serialVersionUID = 42;

  public static class Functionality implements Serializable {
    public T[] createArray(int n) { return (T[])(new Object[n]); }
    public T intern(T x) { return x; } // Override to get desired behavior, e.g., interning
  }
  public static class ObjectFunctionality extends Functionality {
    public Object[] createArray(int n) { return new Object[n]; }
  }
  public static Functionality defaultFunctionality = new Functionality();

  protected static final int growFactor = 2; // How much extra space (times size) to give for the capacity
  protected static final int defaultExpectedSize = 2;
  protected static final double loadFactor = 0.75; // For hash table
  protected enum MapType { SORTED_LIST, HASH_TABLE }

  protected MapType mapType;
  protected boolean locked; // Are the keys locked
  protected int num;
  protected T[] keys;
  protected Functionality keyFunc;
  protected int numCollisions; // For debugging
}