Class AMultiOp<T extends ACell>

Type Parameters:
T - Type of function return
All Implemented Interfaces:
IValidated, IWriteable
Direct Known Subclasses:
Cond, Do, Invoke, Let, Query

public abstract class AMultiOp<T extends ACell> extends AOp<T>
Abstract base class for Ops with multiple nested operations MultiOps may selectively evaluate sub-expressions.
  • Field Details

  • Constructor Details

  • Method Details

    • recreate

      protected abstract AMultiOp<T> recreate(ASequence<AOp<ACell>> newOps)
      Recreates this object with an updated list of child Ops.
      Parameters:
      newOps -
      Returns:
    • encodeRaw

      public int encodeRaw(byte[] bs, int pos)
      Description copied from class: AOp
      Writes the raw data for this Op to the specified bytebuffer. Assumes Op tag and opcode already written.
      Specified by:
      encodeRaw in class AOp<T extends ACell>
      Parameters:
      bs - Byte array to write to
      pos - Position to write in byte array
      Returns:
      The updated position
    • estimatedEncodingSize

      public int estimatedEncodingSize()
      Description copied from interface: IWriteable
      Estimate the encoded data size for this Cell. Used for quickly sizing buffers. Implementations should try to return a size that is highly likely to contain the entire object when encoded, including the tag byte. Should not traverse soft Refs, i.e. must be usable on arbitrary partial data structures
      Specified by:
      estimatedEncodingSize in interface IWriteable
      Overrides:
      estimatedEncodingSize in class AOp<T extends ACell>
      Returns:
      The estimated size for the binary representation of this object.
    • updateRefs

      public AMultiOp<T> updateRefs(IRefFunction func)
      Description copied from class: ACell
      Updates all Refs in this object using the given function. The function *must not* change the hash value of Refs, in order to ensure structural integrity of modified data structures. The implementation *should* re-attach any original encoding in order to prevent re-encoding or surplus hashing This is a building block for a very sneaky trick that enables use to do a lot of efficient operations on large trees of smart references. Must return the same object if no Refs are altered.
      Specified by:
      updateRefs in class AOp<T extends ACell>
      Parameters:
      func - Ref update function
      Returns:
      Cell with updated Refs
    • getRefCount

      public int getRefCount()
      Description copied from class: ACell
      Gets the number of Refs contained within this Cell. This number is final / immutable for any given instance and is defined by the Cell encoding rules. WARNING: may not be valid id Cell is not canonical Contained Refs may be either external or embedded.
      Specified by:
      getRefCount in class ACell
      Returns:
      The number of Refs in this Cell
    • getRef

      public <R extends ACell> Ref<R> getRef(int i)
      Description copied from class: ACell
      Gets a numbered child Ref from within this Cell. WARNING: May be unreliable is cell is not canonical
      Overrides:
      getRef in class ACell
      Type Parameters:
      R - Type of referenced Cell
      Parameters:
      i - Index of ref to get
      Returns:
      The Ref at the specified index
    • validateCell

      public void validateCell() throws InvalidDataException
      Description copied from class: ACell
      Validates the local structure and invariants of this cell. Called by validate() super implementation. Should validate directly contained data, but should not validate all other structure of this cell. In particular, should not traverse potentially missing child Refs.
      Specified by:
      validateCell in class ACell
      Throws:
      InvalidDataException - If the Cell is invalid