diff --git a/src/LedgerEntrySet.cpp b/src/LedgerEntrySet.cpp new file mode 100644 index 0000000000..3ec82c343c --- /dev/null +++ b/src/LedgerEntrySet.cpp @@ -0,0 +1,21 @@ +#include "LedgerEntrySet.h" + +LedgerEntrySet LedgerEntrySet::duplicate() +{ + return LedgerEntrySet(mEntries, mSeq + 1); +} + +void LedgerEntrySet::setTo(LedgerEntrySet& e) +{ + mEntries = e.mEntries; + mSeq = e.mSeq; +} + +void LedgerEntrySet::swapWith(LedgerEntrySet& e) +{ + std::swap(mSeq, e.mSeq); + mEntries.swap(e.mEntries); +} + + + diff --git a/src/LedgerEntrySet.h b/src/LedgerEntrySet.h index 503beca323..d38603b5a7 100644 --- a/src/LedgerEntrySet.h +++ b/src/LedgerEntrySet.h @@ -1,6 +1,8 @@ #ifndef __LEDGERENTRYSET__ #define __LEDGERENTRYSET__ +#include + #include "SerializedLedger.h" enum LedgerEntryAction @@ -10,7 +12,8 @@ enum LedgerEntryAction taaMODIFY, // Modifed, must have previously been taaCACHED. taaDELETE, // Delete, must have previously been taaDELETE or taaMODIFY. taaCREATE, // Newly created. -} +}; + class LedgerEntrySetEntry { @@ -18,15 +21,17 @@ public: SLE::pointer mEntry; LedgerEntryAction mAction; int mSeq; - }; + class LedgerEntrySet { protected: boost::unordered_map mEntries; int mSeq; + LedgerEntrySet(const boost::unordered_map &e, int m) : mEntries(e), mSeq(m) { ; } + public: LedgerEntrySet() : mSeq(0) { ; } @@ -35,6 +40,9 @@ public: void setTo(LedgerEntrySet&); // Set this set to have the same contents as another void swapWith(LedgerEntrySet&); // Swap the contents of two sets + int getSeq() const { return mSeq; } + void bumpSeq() { ++mSeq; } + // basic entry functions SLE::pointer getEntry(const uint256& index, LedgerEntryAction&); LedgerEntryAction hasEntry(const uint256& index) const; @@ -44,11 +52,13 @@ public: void entryModify(SLE::pointer); // This entry will be modified // iterator functions - bool isEmpty() const; - boost::unordered_map::const_iterator begin() const; - boost::unordered_map::const_iterator end() const; - boost::unordered_map::iterator begin(); - boost::unordered_map::iterator end(); + bool isEmpty() const { return mEntries.empty(); } + boost::unordered_map::const_iterator begin() const { return mEntries.begin(); } + boost::unordered_map::const_iterator end() const { return mEntries.end(); } + boost::unordered_map::iterator begin() { return mEntries.begin(); } + boost::unordered_map::iterator end() { return mEntries.end(); } }; #endif + +// vim:ts=4