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

Data structures notes [WIP] #139

Open
Bnaya opened this issue Sep 21, 2020 · 0 comments
Open

Data structures notes [WIP] #139

Bnaya opened this issue Sep 21, 2020 · 0 comments

Comments

@Bnaya
Copy link
Owner

Bnaya commented Sep 21, 2020

Moving forward, seems like we need to implement self balancing binary search tree to be used for quite few parts of the library.
The difficulty would be how to make it generic to several nodes values types.

Allocator part 2

  • part one mostly done
  • TBW part 2
## Allocator part 1 (The allocator is an adaptation of [thing/malloc](https://github.com/thi-ng/umbrella/tree/develop/packages/malloc))
  • freelist
  • one way linked list for used blocks
  • one way linked list for free blocks
  • blocks does not have their size on the end.
  • freeing single pointer
    • Basically adding removing element from the used linked list and adding it to the used list
    • Is O(n), because we need to find the prev node. adding a back link can improve that significantly.
  • merging adjacent free blocks is expensive, need to analyse exact complexity. (It's on by default on free)
    • To efficiently find the physical before block we can add the block size in the block end, to figure out if it's free or not we need a flag or another data structure for fast retrieval

object/map/set

  • linked hashmap
  • does not support deletion current position while iterating (js spec does support it 🥴)
  • as long you don't need rehash you will be fine
    • Consider swapping it with a search tree to avoid rebalancing
  • If we could add static-shaped objects that can be great
  • If we can save the object shape separately - even better

String deduplication

  • Only between strings on the same save operating using js Map
  • Consider adding strings registry in a search tree
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