diff options
author | David Robillard <d@drobilla.net> | 2018-08-18 11:07:42 +0200 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2018-09-29 14:46:32 +0200 |
commit | c5da9a74522967446d796dce5cf9d30ff7b8cec3 (patch) | |
tree | 0f0d06ecc29c7fb9309b61ca2526d7ccefdd536f /chilbert | |
parent | fc24951cba40ab471f64f9f2825b4abe541e1283 (diff) | |
download | chilbert-c5da9a74522967446d796dce5cf9d30ff7b8cec3.tar.gz chilbert-c5da9a74522967446d796dce5cf9d30ff7b8cec3.tar.bz2 chilbert-c5da9a74522967446d796dce5cf9d30ff7b8cec3.zip |
Add comparison operators
Diffstat (limited to 'chilbert')
-rw-r--r-- | chilbert/BigBitVec.hpp | 15 | ||||
-rw-r--r-- | chilbert/FixBitVec.hpp | 2 |
2 files changed, 17 insertions, 0 deletions
diff --git a/chilbert/BigBitVec.hpp b/chilbert/BigBitVec.hpp index 30b8f82..dcc2c99 100644 --- a/chilbert/BigBitVec.hpp +++ b/chilbert/BigBitVec.hpp @@ -108,6 +108,21 @@ public: bool operator!=(const CBigBitVec& vec) const { return !(*this == vec); } + bool operator<(const CBigBitVec& vec) const + { + assert(size() == vec.size()); + + for (size_t ri = 0; ri < m_iRacks; ++ri) { + size_t i = m_iRacks - ri - 1; + if (m_pcRacks[i] < vec.m_pcRacks[i]) { + return true; + } else if (m_pcRacks[i] > vec.m_pcRacks[i]) { + return false; + } + } + return false; + } + /// Non-resizing assignment CBigBitVec& operator=(const CBigBitVec& vec) { diff --git a/chilbert/FixBitVec.hpp b/chilbert/FixBitVec.hpp index 05dae1f..d098956 100644 --- a/chilbert/FixBitVec.hpp +++ b/chilbert/FixBitVec.hpp @@ -115,6 +115,8 @@ public: return m_rack != vec.m_rack; } + bool operator<(const CFixBitVec& vec) const { return m_rack < vec.m_rack; } + CFixBitVec& operator=(const FBV_UINT i) { m_rack = i; |