// Path: src/main/java/com/jordanwilliams/heftydb/table/Table.java
// public interface Table extends Iterable<Tuple>, Comparable<Table> {
// 
//     public long id();
// 
//     public boolean mightContain(Key key);
// 
//     public Tuple get(Key key);
// 
//     public CloseableIterator<Tuple> ascendingIterator(long snapshotId);
// 
//     public CloseableIterator<Tuple> descendingIterator(long snapshotId);
// 
//     public CloseableIterator<Tuple> ascendingIterator(Key key, long snapshotId);
// 
//     public CloseableIterator<Tuple> descendingIterator(Key key, long snapshotId);
// 
//     public long tupleCount();
// 
//     public long size();
// 
//     public int level();
// 
//     public long maxSnapshotId();
// 
//     public void close();
// 
//     public boolean isPersistent();
// }


import com.jordanwilliams.heftydb.table.Table;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.NavigableSet;
import java.util.TreeSet;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
        this.tables.addAll(initialTables);
        this.currentTableId.set(tables.isEmpty() ? 0 : tables.last().id());
    }

    public synchronized void addChangeHandler(ChangeHandler changeHandler) {
        changeHandlers.add(changeHandler);
    }

    public synchronized void removeChangeHandler(ChangeHandler changeHandler) {
        changeHandlers.remove(changeHandler);
    }

    public long nextId() {
        return currentTableId.incrementAndGet();
    }

    public long currentId() {
        return currentTableId.get();
    }

    public void readLock() {
        tableLock.readLock().lock();
    }

    public void readUnlock() {
        tableLock.readLock().unlock();
    }

    public void add(Table toAdd) {
        try {
// Path: src/main/java/com/jordanwilliams/heftydb/table/Table.java
// public interface Table extends Iterable<Tuple>, Comparable<Table> {
// 
//     public long id();
// 
//     public boolean mightContain(Key key);
// 
//     public Tuple get(Key key);
// 
//     public CloseableIterator<Tuple> ascendingIterator(long snapshotId);
// 
//     public CloseableIterator<Tuple> descendingIterator(long snapshotId);
// 
//     public CloseableIterator<Tuple> ascendingIterator(Key key, long snapshotId);
// 
//     public CloseableIterator<Tuple> descendingIterator(Key key, long snapshotId);
// 
//     public long tupleCount();
// 
//     public long size();
// 
//     public int level();
// 
//     public long maxSnapshotId();
// 
//     public void close();
// 
//     public boolean isPersistent();
// }


// Path: src/main/java/com/jordanwilliams/heftydb/state/Tables.java
import com.jordanwilliams.heftydb.table.Table;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.NavigableSet;
import java.util.TreeSet;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;

        this.tables.addAll(initialTables);
        this.currentTableId.set(tables.isEmpty() ? 0 : tables.last().id());
    }

    public synchronized void addChangeHandler(ChangeHandler changeHandler) {
        changeHandlers.add(changeHandler);
    }

    public synchronized void removeChangeHandler(ChangeHandler changeHandler) {
        changeHandlers.remove(changeHandler);
    }

    public long nextId() {
        return currentTableId.incrementAndGet();
    }

    public long currentId() {
        return currentTableId.get();
    }

    public void readLock() {
        tableLock.readLock().lock();
    }

    public void readUnlock() {
        tableLock.readLock().unlock();
    }

    public void add(Table toAdd) {
        try {
            tableLock.writeLock().lock();