Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

evaluate using (linked vectors?) for tack_t #171

Open
lunixbochs opened this issue Mar 27, 2017 · 0 comments
Open

evaluate using (linked vectors?) for tack_t #171

lunixbochs opened this issue Mar 27, 2017 · 0 comments

Comments

@lunixbochs
Copy link
Owner

currently:

malloc(capacity)
on push: if cur >= capacity:
    capacity *= 2; realloc

potentially:

malloc(<initial capacity chosen by profiling, likely at least 9>)
push:
    if pos >= capacity:
        capacity += initial
        last = last->next = malloc(initial)
    last[pos%len] = val
    pos += 1
pop/peek:
    val = last[pos%len]
    if pop:
        cur -= 1
        if pos < capacity - len:
            last = last->prev
            free(last->next);
            last->next = NULL;
    return val
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant