Boron 2.1.0
Datatype Block

Blocks are a series of UCells. More...

Macros

#define ur_blkFree   ur_arrFree
 A block is a simple array.
 

Functions

UIndex ur_makeBlock (UThread *ut, int size)
 Generate a single block of type UT_BLOCK.
 
UBufferur_makeBlockCell (UThread *ut, int type, int size, UCell *cell)
 Generate a single block and set cell to reference it.
 
void ur_blkInit (UBuffer *buf, int type, int size)
 Initialize block buffer.
 
UCellur_blkAppendNew (UBuffer *buf, int type)
 Add cell to end of block.
 
void ur_blkAppendCells (UBuffer *buf, const UCell *cells, int count)
 Append cells to block.
 
void ur_blkInsert (UBuffer *buf, UIndex it, const UCell *cells, int count)
 Insert cells into block.
 
void ur_blkPush (UBuffer *buf, const UCell *cell)
 Copy cell to end of block.
 
UCellur_blkPop (UBuffer *buf)
 Remove cell from end of block.
 
void ur_blkSlice (UThread *ut, UBlockIter *bi, const UCell *cell)
 Set UBlockIter to block slice.
 
UStatus ur_blkSliceM (UThread *ut, UBlockIterM *bi, const UCell *cell)
 Set UBlockIterM to block slice.
 
UIndex ur_blkClone (UThread *ut, UIndex blkN)
 Make deep copy of block.
 
void ur_blkCollectType (UThread *ut, const UCell *blkCell, uint32_t typeMask, UBuffer *dest, int unique)
 Find all values of a certain type and append them to another block.
 

Detailed Description

Blocks are a series of UCells.

Function Documentation

◆ ur_blkAppendCells()

void ur_blkAppendCells ( UBuffer * buf,
const UCell * cells,
int count )

Append cells to block.

Parameters
bufInitialized block buffer.
cellsCells to copy.
countNumber of cells to copy.

◆ ur_blkAppendNew()

UCell * ur_blkAppendNew ( UBuffer * buf,
int type )

Add cell to end of block.

Returns
Pointer to new cell. Only the cell id is initialized; other members are unset.

◆ ur_blkClone()

UIndex ur_blkClone ( UThread * ut,
UIndex blkN )

Make deep copy of block.

Parameters
blkNBuffer id of block to clone.
Returns
Buffer id of new block.

◆ ur_blkCollectType()

void ur_blkCollectType ( UThread * ut,
const UCell * blkCell,
uint32_t typeMask,
UBuffer * dest,
int unique )

Find all values of a certain type and append them to another block.

Parameters
blkCellCell of block or paren to recursively search.
typeMaskBit mask of datatypes to collect.
destMatching values are copied to this block buffer.
uniqueOnly add equal values once to dest.

◆ ur_blkInit()

void ur_blkInit ( UBuffer * buf,
int type,
int size )

Initialize block buffer.

Parameters
typeBuffer type (Normally UT_BLOCK).
sizeNumber of cells to reserve.

◆ ur_blkInsert()

void ur_blkInsert ( UBuffer * buf,
UIndex it,
const UCell * cells,
int count )

Insert cells into block.

This performs a memcpy, so the source cells must not overlap the buf cells.

Parameters
bufInitialized block buffer.
itPosition in buf.
cellsCells to copy.
countNumber of cells to copy.

◆ ur_blkPop()

UCell * ur_blkPop ( UBuffer * buf)

Remove cell from end of block.

Returns
Pointer to what was the last cell, or zero if block is empty.

◆ ur_blkSlice()

void ur_blkSlice ( UThread * ut,
UBlockIter * bi,
const UCell * cell )

Set UBlockIter to block slice.

If the UBlockIter::buf pointer is not needed it is recommended to use ur_blockIt() instead.

Parameters
biIterator struct to fill.
cellPointer to a valid block cell.
Returns
Initializes bi. If slice is empty then bi->it and bi->end are set to zero.
See also
ur_blockIt, ur_blkSliceM

◆ ur_blkSliceM()

UStatus ur_blkSliceM ( UThread * ut,
UBlockIterM * bi,
const UCell * cell )

Set UBlockIterM to block slice.

If cell references a block in shared storage then an error is generated and UR_THROW is returned. Otherwise, bi is initialized. If the slice is empty then bi->it and bi->end are set to zero.

Parameters
biIterator struct to fill.
cellPointer to a valid block cell.
Returns
UR_OK/UR_THROW
See also
ur_blockIt, ur_blkSlice

◆ ur_makeBlock()

UIndex ur_makeBlock ( UThread * ut,
int size )

Generate a single block of type UT_BLOCK.

If you need multiple buffers then ur_genBuffers() should be used.

The caller must create a UCell for this block in a held block before the next ur_recycle() or else it will be garbage collected.

Parameters
sizeNumber of cells to reserve.
Returns
Buffer id of block.

◆ ur_makeBlockCell()

UBuffer * ur_makeBlockCell ( UThread * ut,
int type,
int size,
UCell * cell )

Generate a single block and set cell to reference it.

If you need multiple buffers then ur_genBuffers() should be used.

Parameters
typeType (UT_BLOCK, UT_PAREN, etc.).
sizeNumber of cells to reserve.
cellCell to initialize.
Returns
Pointer to block buffer.