diff options
author | Michele Calgaro <michele.calgaro@yahoo.it> | 2022-05-06 13:43:02 +0900 |
---|---|---|
committer | Michele Calgaro <michele.calgaro@yahoo.it> | 2022-05-06 13:49:57 +0900 |
commit | 80a31d6c8a114799dc5284086ffce2e9be34c50e (patch) | |
tree | 1719891657e76c04f063f5ff7b5fdf63d9e562c3 /debian/uncrustify-trinity/uncrustify-trinity-0.75.0/src/ChunkStack.cpp | |
parent | e6ba08c3b21cdb14ee3a97b5d584759a4597b54b (diff) | |
download | extra-dependencies-80a31d6c8a114799dc5284086ffce2e9be34c50e.tar.gz extra-dependencies-80a31d6c8a114799dc5284086ffce2e9be34c50e.zip |
uncrustify-trinity: updated based on upstream version 0.75.0
Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
Diffstat (limited to 'debian/uncrustify-trinity/uncrustify-trinity-0.75.0/src/ChunkStack.cpp')
-rw-r--r-- | debian/uncrustify-trinity/uncrustify-trinity-0.75.0/src/ChunkStack.cpp | 120 |
1 files changed, 120 insertions, 0 deletions
diff --git a/debian/uncrustify-trinity/uncrustify-trinity-0.75.0/src/ChunkStack.cpp b/debian/uncrustify-trinity/uncrustify-trinity-0.75.0/src/ChunkStack.cpp new file mode 100644 index 00000000..dfa0f888 --- /dev/null +++ b/debian/uncrustify-trinity/uncrustify-trinity-0.75.0/src/ChunkStack.cpp @@ -0,0 +1,120 @@ +/** + * @file ChunkStack.cpp + * Manages a chunk stack + * + * @author Ben Gardner + * @license GPL v2+ + */ + +#include "ChunkStack.h" + + +void ChunkStack::Set(const ChunkStack &cs) +{ + m_cse.resize(cs.m_cse.size()); + + for (size_t idx = 0; idx < m_cse.size(); idx++) + { + m_cse[idx].m_pc = cs.m_cse[idx].m_pc; + m_cse[idx].m_seqnum = cs.m_cse[idx].m_seqnum; + } + + m_seqnum = cs.m_seqnum; +} + + +const ChunkStack::Entry *ChunkStack::Top() const +{ + if (!m_cse.empty()) + { + return(&m_cse[m_cse.size() - 1]); + } + return(nullptr); +} + + +const ChunkStack::Entry *ChunkStack::Get(size_t idx) const +{ + if (idx < m_cse.size()) + { + return(&m_cse[idx]); + } + return(nullptr); +} + + +Chunk *ChunkStack::GetChunk(size_t idx) const +{ + if (idx < m_cse.size()) + { + return(m_cse[idx].m_pc); + } + return(nullptr); +} + + +Chunk *ChunkStack::Pop_Front() +{ + Chunk *pc = nullptr; + + if (!m_cse.empty()) + { + pc = m_cse[0].m_pc; + m_cse.pop_front(); + } + return(pc); +} + + +Chunk *ChunkStack::Pop_Back() +{ + Chunk *pc = nullptr; + + if (!m_cse.empty()) + { + pc = m_cse[m_cse.size() - 1].m_pc; + m_cse.pop_back(); + } + return(pc); +} + + +void ChunkStack::Push_Back(Chunk *pc, size_t seqnum) +{ + m_cse.push_back(Entry(seqnum, pc)); + + if (m_seqnum < seqnum) + { + m_seqnum = seqnum; + } +} + + +void ChunkStack::Zap(size_t idx) +{ + if (idx < m_cse.size()) + { + m_cse[idx].m_pc = nullptr; + } +} + + +void ChunkStack::Collapse() +{ + size_t wr_idx = 0; + + for (size_t rd_idx = 0; rd_idx < m_cse.size(); rd_idx++) + { + if (m_cse[rd_idx].m_pc != nullptr) + { + if (rd_idx != wr_idx) + { + m_cse[wr_idx].m_pc = m_cse[rd_idx].m_pc; + m_cse[wr_idx].m_seqnum = m_cse[rd_idx].m_seqnum; + } + wr_idx++; + } + } + + m_cse.resize(wr_idx); +} |