// Path: src/io/lacuna/bifurcan/IDurableCollection.java
// interface Fingerprint extends Comparable<Fingerprint> {
//   String ALGORITHM = "SHA-512";
//   int HASH_BYTES = 32;
// 
//   byte[] binary();
// 
//   default String toHexString() {
//     return Bytes.toHexString(ByteBuffer.wrap(binary()));
//   }
// 
//   default int compareTo(Fingerprint o) {
//     return Bytes.compareBuffers(
//         ByteBuffer.wrap(binary()),
//         ByteBuffer.wrap(o.binary())
//     );
//   }
// }


import io.lacuna.bifurcan.*;
import io.lacuna.bifurcan.IDurableCollection.Fingerprint;
import java.util.stream.LongStream;
package io.lacuna.bifurcan.durable;



public class Dependencies {

  private static ThreadLocal<LinearSet<Fingerprint>> ROOT_DEPENDENCIES = new ThreadLocal<>();

  public static void enter() {
    ROOT_DEPENDENCIES.set(new LinearSet<>());
  }

  public static void add(Fingerprint fingerprint) {
    ROOT_DEPENDENCIES.get().add(fingerprint);
  }

  public static ISet<Fingerprint> exit() {
    ISet<Fingerprint> dependencies = ROOT_DEPENDENCIES.get();
    ROOT_DEPENDENCIES.set(null);
    return dependencies;
  }

// Path: src/io/lacuna/bifurcan/IDurableCollection.java
// interface Fingerprint extends Comparable<Fingerprint> {
//   String ALGORITHM = "SHA-512";
//   int HASH_BYTES = 32;
// 
//   byte[] binary();
// 
//   default String toHexString() {
//     return Bytes.toHexString(ByteBuffer.wrap(binary()));
//   }
// 
//   default int compareTo(Fingerprint o) {
//     return Bytes.compareBuffers(
//         ByteBuffer.wrap(binary()),
//         ByteBuffer.wrap(o.binary())
//     );
//   }
// }


// Path: src/io/lacuna/bifurcan/durable/Dependencies.java
import io.lacuna.bifurcan.*;
import io.lacuna.bifurcan.IDurableCollection.Fingerprint;
import java.util.stream.LongStream;

package io.lacuna.bifurcan.durable;



public class Dependencies {

  private static ThreadLocal<LinearSet<Fingerprint>> ROOT_DEPENDENCIES = new ThreadLocal<>();

  public static void enter() {
    ROOT_DEPENDENCIES.set(new LinearSet<>());
  }

  public static void add(Fingerprint fingerprint) {
    ROOT_DEPENDENCIES.get().add(fingerprint);
  }

  public static ISet<Fingerprint> exit() {
    ISet<Fingerprint> dependencies = ROOT_DEPENDENCIES.get();
    ROOT_DEPENDENCIES.set(null);
    return dependencies;
  }

  public static void encode(ISet<Fingerprint> dependencies, DurableOutput out) {