BiPartition.java

  1. package org.heigit.ors.fastisochrones.partitioning;

  2. import com.carrotsearch.hppc.IntHashSet;

  3. /**
  4.  * Helper class for keeping track of a node partitioning based on IntHashSets.
  5.  *
  6.  * @author Hendrik Leuschner
  7.  */
  8. class BiPartition {
  9.     private final IntHashSet partition0;
  10.     private final IntHashSet partition1;

  11.     public BiPartition() {
  12.         this.partition0 = new IntHashSet(0);
  13.         this.partition1 = new IntHashSet(0);
  14.     }

  15.     public BiPartition(IntHashSet partition0, IntHashSet partition1) {
  16.         this.partition0 = partition0;
  17.         this.partition1 = partition1;
  18.     }

  19.     public IntHashSet getPartition(int partitionNumber) {
  20.         if (partitionNumber != 0 && partitionNumber != 1)
  21.             throw new IllegalArgumentException("Only 2 partitions supported");
  22.         return partitionNumber == 0 ? partition0 : partition1;
  23.     }
  24. }