index.js

js · 70 lines · part of aaa · raw

/*

A fast array is a trie-like data structure that allows for fast insertion and removal of elements
at any index. It is useful for cases where you need to insert and remove elements at arbitrary
indices in an array-like data structure.



a.aa.aaa.aaaa.aaaaa.aaaaaa.aaaaaaa.aaaaaaaa.aaaaaaaaa.aaaaaaaaaa.aaaaaaaaaaa.aaaaaaaaaaaa

b.aa.aaa.aaaa.aaaaa.aaaaaa.aaaaaaa.aaaaaaaa.aaaaaaaaa.aaaaaaaaaa.aaaaaaaaaaa.aaaaaaaaaaaa

z.zz.zzz.zzzz.zzzzz.zzzzzz.zzzzzzz.zzzzzzzz.zzzzzzzzz.zzzzzzzzzz.zzzzzzzzzzz.zzzzzzzzzzzz


*/

const Meta = require('Meta')

const FastArray = {

    ID: Meta.Object({
        value: 'Collection.Array,.Of(Maths.Integer.Number)',
    }),

    Node: Meta.Object({
        size: 'Maths.Integer.Number',
        zero: 'Collection.Optional.Of(FastArray.Node)',
        one: 'Collection.Optional.Of(FastArray.Node)',
    }),

    Create: Meta.Function('FastArray.Node', () => {
        return FastArray.Node( 0, undefined, undefined )
    }),

    Insert: Meta.Function('FastArray.Node', () => {
        const array = Meta.Input('FastArray.Node')
        const index = Meta.Input('Maths.Integer.Number')
        const value = Meta.Input('Type(0)')
}
    }),



}

function arrayCreate() {
    return {
        length: 0,

    }
}

function arrayInsert( array, index, value ) {
    //  Find the ID at this index and the preceding one
    const id = '123'
    const element = { id, value }

}

function arrayRemove( array, index ) {
    //  Find the ID at this index

}

function _arrayNodeCreate() {
    const
        return { id, values: [] }
}