2 * Copyright 2014, Paweł Dziepak, pdziepak@quarnos.org.
3 * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
4 * Distributed under the terms of the MIT License.
16 #define PAGE_MASK (B_PAGE_SIZE - 1)
18 #define PAGE_OFFSET(x) ((x) & (PAGE_MASK))
19 #define PAGE_BASE(x) ((x) & ~(PAGE_MASK))
20 #define TO_PAGE_SIZE(x) ((x + (PAGE_MASK)) & ~(PAGE_MASK))
23 extern "C" void dprintf(const char *format
, ...);
34 void push_back(const T
& value
);
35 void pop_back() { fSize
--; }
37 T
& back() { return fData
[fSize
- 1]; }
39 T
& operator[](size_t idx
) { return fData
[idx
]; }
40 const T
& operator[](size_t idx
) const { return fData
[idx
]; }
42 size_t size() const { return fSize
; }
43 bool empty() const { return size() == 0; }
66 vector
<T
>::push_back(const T
& value
)
68 if (fSize
+ 1 > fMaxSize
)
70 fData
[fSize
++] = value
;
78 size_t newSize
= std::max(fMaxSize
* 2, size_t(4));
79 T
* newBuffer
= new T
[newSize
];
81 memcpy(newBuffer
, fData
, fSize
* sizeof(T
));
89 } // namespace utility