There is a great idea of Data.Ix implemented for nice and fast Data.Array.Unboxed and others. That allows to form arrays, matrices and other schemas (even triangles) of data access. To gain that flexibility we separate storage implementation (i.e. continous sequence of bytes) from indexing schema implementation.
But sometimes we need a way to access more complex objects and still have that magic Unboxed storage. I.e. instead of accessing single object we need two of them. Once again mighty of Haskell type system comes to save us. Just add another index axis and hide it in the same way how Ix do.
Showing posts with label data-structures. Show all posts
Showing posts with label data-structures. Show all posts
2011-12-15
2011-10-14
Hand-made allocator
Today I was asked at interview to write my own allocator in ANSI C. Pretty strange task as for me. You need some time to debug and doing that at paper is awful. So I've put simple single-listed allocator without merging free space. And of course I forgot to hanle some simple cases.
Let's see how it should look:2010-06-08
intset
There is std::vector specialization known as bit_vector. In the same way there may exist set of integers by using pages of bits accessed through std::map.
Subscribe to:
Posts (Atom)