| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- #include "IteratorDemo.h"
- #include "RingQueue.hpp"
- struct User_t
- {
- int id;
- std::string name;
- };
- void testRingQueueManualMutex()
- {
- RingQueueManualMutex<User_t> queue(5);
- queue.push({1, "Alice"});
- queue.push({2, "Bob"});
- queue.push({3, "Charlie"});
- queue.push({4, "Diana"});
- queue.push({5, "Ethan"});
-
- for(auto it : queue)
- {
- SPDLOG_INFO("Value: id={}, name={}", it.id, it.name);
- }
- SPDLOG_INFO("---------------------------------------------");
- SPDLOG_INFO("倒叙遍历: ");
- auto it = queue.end();
- --it;
- for(; it != queue.begin(); it--)
- {
- SPDLOG_INFO("Value: id={}, name={}", it->id, it->name);
- }
- SPDLOG_INFO("Value: id={}, name={}", it->id, it->name);
- SPDLOG_INFO("RingQueueManualMutex 测试完成");
- }
- void testRingQueue()
- {
- RingQueue<User_t> queue;
- queue.push({1, "Alice"});
- queue.push({2, "Bob"});
- queue.push({3, "Charlie"});
- // for(const auto& user : queue)
- // {
- // SPDLOG_INFO("User ID: {}, Name: {}", user.id, user.name);
- // }
- }
|