Skip to content

Commit

Permalink
Add initial version
Browse files Browse the repository at this point in the history
  • Loading branch information
zMoooooritz committed Jul 25, 2022
0 parents commit 8a8f4c5
Show file tree
Hide file tree
Showing 8 changed files with 1,354 additions and 0 deletions.
59 changes: 59 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Created by https://www.toptal.com/developers/gitignore/api/c++,vim
# Edit at https://www.toptal.com/developers/gitignore?templates=c++,vim

### C++ ###
# Prerequisites
*.d

# Compiled Object files
*.slo
*.lo
*.o
*.obj

# Precompiled Headers
*.gch
*.pch

# Compiled Dynamic libraries
*.so
*.dylib
*.dll

# Fortran module files
*.mod
*.smod

# Compiled Static libraries
*.lai
*.la
*.a
*.lib

# Executables
*.exe
*.out
*.app

### Vim ###
# Swap
[._]*.s[a-v][a-z]
!*.svg # comment out if you don't need vector files
[._]*.sw[a-p]
[._]s[a-rt-v][a-z]
[._]ss[a-gi-z]
[._]sw[a-p]

# Session
Session.vim
Sessionx.vim

# Temporary
.netrwhist
*~
# Auto-generated tag files
tags
# Persistent undo
[._]*.un~

# End of https://www.toptal.com/developers/gitignore/api/c++,vim
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2022 Moritz Biering

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
26 changes: 26 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

SHELL = /bin/sh

NAME = ditvector
CC = g++
CFLAGS = -Wall -g -std=c++20

.PHONY: all test clean info

all: test

test: test.o
@$(CC) $(CFLAGS) -o test test.o

profile: test.o
@$(CC) $(CFLAGS) -pg -o profile test.o

test.o: test.cpp avl.hpp bit_vector.hpp bit_vector.cpp
@$(CC) $(CFLAGS) -c test.cpp

clean:
@rm -rf *.o

info:
@echo ""

31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# ditvector

A dynamic bitvector that support rank and select queries.

The datastructure allows for one template argument that defines the size of the bitblocks stored in leaf.
This parameter can be used to select the appropriate trade-off between space and time complexity.
As a sensible default a size of 512 bits is used.

## Operations

The datastructure supports the following instructions which all have logarithmic runtime.
* insert(index, true/false)
* del(index)
* set(index)
* unset(index)
* flip(index)
* rank(index, true/false)
* select(index, true/false)

## Usage

```c++
BitVector<> bv;
bv.insert(0, false);
bv.insert(0, true);
bv.access(0); // true
bv.rank(1, true); // 1
bv.flip(0);
bv.rank(1, true); // 0
```

Loading

0 comments on commit 8a8f4c5

Please sign in to comment.