Skip to content

scan() with boundary control #4

@tomijaga

Description

@tomijaga

Current

btree.insert("a", 1);
btree.insert("alphabet", 2);
btree.insert("b", 3);

let iter = btree.scan(?"a", ?"alphabet");

// iter -> ("a", 1), ("alphabet", 2)

Proposed change

Suppose I wanted to search for all words between "a" and "b" but didn't know the last word starting with "a" was alphabet, I wouldn't be able to do that with the existing scan() method. Enter scanBoundary():

type Boundary<K> = {
    #Inclusive: K;
    #Exclusive: K;
};

let iter = btree.scanBoundary(?#Inclusive("a"), ?#Exclusive("b"));

// iter -> ("a", 1), ("alphabet", 2)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions