Class StructStore

java.lang.Object
io.keikai.doc.collab.utils.StructStore

public class StructStore extends Object
  • Constructor Details

    • StructStore

      public StructStore()
  • Method Details

    • getClients

      public Map<Integer,List<AbstractStruct>> getClients()
    • getPendingStructs

      public StructResult getPendingStructs()
    • setPendingStructs

      public void setPendingStructs(StructResult pendingStructs)
    • getPendingDs

      public Uint8Array getPendingDs()
    • setPendingDs

      public void setPendingDs(Uint8Array pendingDs)
    • getStateVector

      public static Map<Integer,Integer> getStateVector(StructStore store)
      Return the states as a Map<client,clock>. Note that clock refers to the next expected clock id.
      Parameters:
      store -
      Returns:
    • getState

      public static int getState(StructStore store, int client)
    • integrityCheck

      public static void integrityCheck(StructStore store)
    • addStruct

      public static void addStruct(StructStore store, AbstractStruct struct)
    • findIndexSS

      public static int findIndexSS(List<AbstractStruct> structs, int clock)
      Perform a binary search on a sorted array
      Parameters:
      structs -
      clock -
      Returns:
    • find

      public static AbstractStruct find(StructStore store, ID id)
      Expects that id is actually in store. This function throws or is an infinite loop otherwise.
      Parameters:
      store -
      id -
      Returns:
    • getItem

      public static AbstractStruct getItem(StructStore store, ID id)
      Expects that id is actually in store. This function throws or is an infinite loop otherwise.
      Parameters:
      store -
      id -
      Returns:
    • findIndexCleanStart

      public static int findIndexCleanStart(Transaction transaction, List<AbstractStruct> structs, int clock)
    • getItemCleanStart

      public static Item getItemCleanStart(Transaction transaction, ID id)
      Expects that id is actually in store. This function throws or is an infinite loop otherwise.
      Parameters:
      transaction -
      id -
      Returns:
    • getItemCleanEnd

      public static AbstractStruct getItemCleanEnd(Transaction transaction, StructStore store, ID id)
      Expects that id is actually in store. This function throws or is an infinite loop otherwise.
      Parameters:
      transaction -
      store -
      id -
      Returns:
    • replaceStruct

      public static void replaceStruct(StructStore store, AbstractStruct struct, AbstractStruct newStruct)
      Replace `item` with `newitem` in store
      Parameters:
      store -
      struct -
      newStruct -
    • iterateStructs

      public static void iterateStructs(Transaction transaction, List<AbstractStruct> structs, int clockStart, int len, Consumer<AbstractStruct> f)
      Iterate over a range of structs
      Parameters:
      transaction -
      structs -
      clockStart - Inclusive start
      len -
      f -