Skip to content

JayTwoLab/BitArray

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BitArray

*Read this in other languages: English, 🇰🇷 Korean


BitArray is a lightweight class for bit-level data manipulation and management.
It is implemented in both C++ and Python, and can be used in areas such as networking, data compression, and binary analysis.

📁 Project Structure

BitArray-main/
├── cpp/             # C++ implementation
│   ├── main.cpp
│   └── README.md
├── python/          # Python implementation
│   ├── BitArray.py
│   └── README.md
├── README.md        # Project introduction
├── LICENSE
└── .gitignore

💡 Feature Summary

Feature Description
Bit Initialization Create bit arrays from byte arrays or specified bit sizes
Bit Extraction Extract sub-bit arrays based on offset and length
Bit Merging Merge another bit array at a specified position
Bit Operations Supports operators like +, <<, >>
Bit Reversal Supports reverser() to reverse bit order
Visualization Print bits in human-readable format using print, dump
Unit Testing Includes test code for various operations

🧠 Language Implementations

✅ C++

  • Source files: cpp/
  • Main class: BitArray
  • High-performance implementation based on STL
  • Includes unit test (main.cpp)
  • Highlights:
    • Uses std::vector<uint8_t> for storage
    • Offers various bit manipulation methods like get, merge, toArray, dump

📄 More details: cpp/README.md


✅ Python

  • Source files: python/
  • Main class: BitArray
  • Implemented using Python lists and bit manipulation
  • Highlights:
    • Supports merging and extracting bit arrays
    • Provides to_array, to_int_array, reverser, __add__, __rshift__, __lshift__
    • Includes unit test function

📄 More details: python/README.md


🔬 Usage Examples

C++ Example

BitArray a({0b11000000}, 3);
a.print();  // Output: 110

BitArray b({0b01000000}, 2);
auto c = a + b;
c.print();  // Output: 11001

Python Example

bit_array = BitArray([0b11000000], 8)
bit_array.print()  # Output: 1100 0000

sub_array = bit_array.get(2, 3)
sub_array.print()  # Output: 000

🔧 Installation and Execution

C++

cd cpp
g++ main.cpp -std=c++17 -o bitarray
./bitarray

Python

cd python
python3 BitArray.py  # Runs runTests() internally

🧪 Testing

Each implementation includes unit test code to verify functionality upon execution.


📜 License

About

🇰🇷 C++ 와 Python 이 지원되는 비트(bit) 처리 클래스

Resources

License

Stars

Watchers

Forks

Packages

No packages published