summaryrefslogtreecommitdiff
path: root/AK/CircularQueue.h
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-02-26 02:17:25 +0100
committerAndreas Kling <awesomekling@gmail.com>2019-02-26 02:17:25 +0100
commit2fb3fa7f69791e908d37cd508e8891e9219009fc (patch)
tree64c417d8eb444b025bb95c15c13c1531dd652b8b /AK/CircularQueue.h
parentb341cab9cc9f3fb999d6fe138ef5604915d426da (diff)
downloadserenity-2fb3fa7f69791e908d37cd508e8891e9219009fc.zip
WindowServer: Add a simple CPU usage graph to the global menu bar.
This is pretty cute and helps me spot when something's chewing up CPU.
Diffstat (limited to 'AK/CircularQueue.h')
-rw-r--r--AK/CircularQueue.h18
1 files changed, 9 insertions, 9 deletions
diff --git a/AK/CircularQueue.h b/AK/CircularQueue.h
index acb91216b9..0dc39afdec 100644
--- a/AK/CircularQueue.h
+++ b/AK/CircularQueue.h
@@ -5,25 +5,25 @@
namespace AK {
-template<typename T, size_t Capacity>
+template<typename T, int Capacity>
class CircularQueue {
public:
CircularQueue()
{
- for (size_t i = 0; i < Capacity; ++i)
+ for (int i = 0; i < Capacity; ++i)
m_elements[i] = T();
}
bool is_empty() const { return !m_size; }
- size_t size() const { return m_size; }
+ int size() const { return m_size; }
- size_t capacity() const { return Capacity; }
+ int capacity() const { return Capacity; }
void dump() const
{
kprintf("CircularQueue<%zu>:\n", Capacity);
kprintf(" size: %zu\n", m_size);
- for (size_t i = 0; i < Capacity; ++i) {
+ for (int i = 0; i < Capacity; ++i) {
kprintf(" [%zu] %d %c\n", i, m_elements[i], i == m_head ? '*' : ' ');
}
}
@@ -60,9 +60,9 @@ public:
const T& operator*() const { return m_queue.m_elements[m_index]; }
private:
friend class CircularQueue;
- ConstIterator(const CircularQueue& queue, const size_t index) : m_queue(queue), m_index(index) { }
+ ConstIterator(const CircularQueue& queue, const int index) : m_queue(queue), m_index(index) { }
const CircularQueue& m_queue;
- size_t m_index { 0 };
+ int m_index { 0 };
};
ConstIterator begin() const { return ConstIterator(*this, m_head); }
@@ -71,8 +71,8 @@ public:
private:
friend class ConstIterator;
T m_elements[Capacity];
- size_t m_size { 0 };
- size_t m_head { 0 };
+ int m_size { 0 };
+ int m_head { 0 };
};
}