edu.stanford.math.plex
public class SimplexTable extends java.lang.Object implements java.lang.Iterable<Simplex>
SimplexTable
is an interning table for instances of
Simplex. That is, the simplices in the table are both key and
value. There is no removal operation, and putting a simplex equivalent
to one already in the table throws an IllegalArgumentException. The
largest table we can make will hold around 976M simplices. Attempting to
add a simplex to table that is full throwns an IllegalStateException.Modifier and Type | Class and Description |
---|---|
protected static class |
SimplexTable.SimpleTableIterator
Instances provide Iterator
|
Modifier and Type | Field and Description |
---|---|
protected int |
entry_limit |
protected static double |
LOAD_FACTOR |
protected int |
mask |
protected int |
MAX_ENTRY_LIMIT |
protected int |
MAX_TABLE_SIZE |
protected int |
size |
protected Simplex[] |
table |
Modifier | Constructor and Description |
---|---|
protected |
SimplexTable() |
|
SimplexTable(int limit)
Make a new SimplexTable.
|
Modifier and Type | Method and Description |
---|---|
Simplex |
get(Simplex s)
Get the interned version of the Simplex s.
|
Simplex |
getInterned(Simplex s)
Return the interned version of a Simplex.
|
protected void |
grow_table(int newLimit) |
java.util.Iterator<Simplex> |
iterator()
Make an iterator for the table.
|
int |
limit()
The number of simplices that can be interned before growing the table.
|
Simplex |
put(Simplex s)
Intern a Simplex.
|
int |
size()
The number of simplices that have been interned.
|
protected int size
protected int entry_limit
protected int mask
protected Simplex[] table
protected static final double LOAD_FACTOR
protected int MAX_TABLE_SIZE
protected int MAX_ENTRY_LIMIT
protected SimplexTable()
public SimplexTable(int limit)
You must make sure that limit is as large as the number of simplices you will be storing in the table, as the table will NOT grow, and attempting to add simplices past the limit throws an exception which isn't caught in the Persistence algorithm.
limit
- An upper bound on the number of simplices that
will be interned in the table -- must be less than or equal
to MAX_ENTRY_LIMIT (which is about 976M).java.lang.IllegalArgumentException
System.getProperty(java.lang.String)
,
SecurityManager.checkPermission(java.security.Permission)
protected void grow_table(int newLimit)
public int size()
public int limit()
public Simplex get(Simplex s)
Because the CRC hashing -- which we use for simplices -- is good, we just mask the hash code for our initial index. We keep the table sufficiently empty that we don't get a lot of false hits, so we reprobe with increment 1 to improve locality of reference in these (potentially) very large tables.
s
- The simplex for which we want an interned version.public Simplex put(Simplex s)
Intern s in the table. When used by the Persistence algorithm, s should be a Simplex from the SimplexStream, which means that it will the filtration index set. An attempt to intern the same simplex twice throws an exception.
s
- the Simplex to internjava.lang.IllegalStateException
- when attempting to grow too big.java.lang.IllegalArgumentException
- when attempting to put a Simplex twice.public Simplex getInterned(Simplex s)
Like put(), except no error if something is already in the table.
s
- the Simplex keyjava.lang.IllegalStateException
- when attempting to grow too big.