Package io.keikai.doc.collab.utils
Class StructStore
- java.lang.Object
-
- io.keikai.doc.collab.utils.StructStore
-
public class StructStore extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description StructStore()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static voidaddStruct(StructStore store, AbstractStruct struct)static AbstractStructfind(StructStore store, ID id)Expects that id is actually in store.static intfindIndexCleanStart(Transaction transaction, java.util.List<AbstractStruct> structs, int clock)static intfindIndexSS(java.util.List<AbstractStruct> structs, int clock)Perform a binary search on a sorted arrayjava.util.Map<java.lang.Integer,java.util.List<AbstractStruct>>getClients()static AbstractStructgetItem(StructStore store, ID id)Expects that id is actually in store.static AbstractStructgetItemCleanEnd(Transaction transaction, StructStore store, ID id)Expects that id is actually in store.static ItemgetItemCleanStart(Transaction transaction, ID id)Expects that id is actually in store.Uint8ArraygetPendingDs()StructResultgetPendingStructs()static intgetState(StructStore store, int client)static java.util.Map<java.lang.Integer,java.lang.Integer>getStateVector(StructStore store)Return the states as aMap<client,clock>.static voidintegrityCheck(StructStore store)static voiditerateStructs(Transaction transaction, java.util.List<AbstractStruct> structs, int clockStart, int len, java.util.function.Consumer<AbstractStruct> f)Iterate over a range of structsstatic voidreplaceStruct(StructStore store, AbstractStruct struct, AbstractStruct newStruct)Replace `item` with `newitem` in storevoidsetPendingDs(Uint8Array pendingDs)voidsetPendingStructs(StructResult pendingStructs)
-
-
-
Method Detail
-
getClients
public java.util.Map<java.lang.Integer,java.util.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 java.util.Map<java.lang.Integer,java.lang.Integer> getStateVector(StructStore store)
Return the states as aMap<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(java.util.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, java.util.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, java.util.List<AbstractStruct> structs, int clockStart, int len, java.util.function.Consumer<AbstractStruct> f)
Iterate over a range of structs- Parameters:
transaction-structs-clockStart- Inclusive startlen-f-
-
-