Remove `virtual` from the inner module names to avoid repetition.
Rename `RawVirtualVec` to `VirtualRawVec` so it's more consistent.
use std::ptr;
use std::slice;
-use super::RawVirtualVec;
+use super::VirtualRawVec;
const INITIAL_CAPACITY: usize = 7; // 2^3 - 1
const MINIMUM_CAPACITY: usize = 1; // 2 - 1
pub struct VirtualDeque<T> {
- buf: RawVirtualVec<T>,
+ buf: VirtualRawVec<T>,
head: usize,
tail: usize,
}
assert!(max_capacity < std::isize::MAX as usize);
let cap = std::cmp::max(capacity + 1, MINIMUM_CAPACITY + 1).next_power_of_two();
Self {
- buf: RawVirtualVec::with_capacity(cap, max_capacity),
+ buf: VirtualRawVec::with_capacity(cap, max_capacity),
head: 0,
tail: 0,
}
-mod raw_virtual_vec;
-mod virtual_deque;
-mod virtual_vec;
+mod deque;
+mod raw_vec;
+mod vec;
-pub use self::raw_virtual_vec::RawVirtualVec;
-pub use self::virtual_deque::VirtualDeque;
-pub use self::virtual_vec::VirtualVec;
+pub use self::deque::VirtualDeque;
+pub use self::raw_vec::VirtualRawVec;
+pub use self::vec::VirtualVec;
#[cfg(test)]
mod tests {
use crate::{page_size, virtual_commit, virtual_free, virtual_reserve};
-pub struct RawVirtualVec<T> {
+pub struct VirtualRawVec<T> {
ptr: NonNull<T>,
cap: usize,
max_cap: usize,
}
-impl<T> RawVirtualVec<T> {
+impl<T> VirtualRawVec<T> {
pub fn new(max_capacity: usize) -> Self {
assert!(max_capacity != 0);
}
}
-impl<T> Drop for RawVirtualVec<T> {
+impl<T> Drop for VirtualRawVec<T> {
fn drop(&mut self) {
unsafe {
// The preconditions here that max_cap multiplied by the size won't overflow and
use std::ops::{Deref, DerefMut};
use std::ptr;
-use super::RawVirtualVec;
+use super::VirtualRawVec;
pub struct VirtualVec<T> {
- buf: RawVirtualVec<T>,
+ buf: VirtualRawVec<T>,
len: usize,
}
/// Panics if the memory reservation fails, or if there's any overflow in the size calculations.
pub fn new(max_capacity: usize) -> Self {
Self {
- buf: RawVirtualVec::new(max_capacity),
+ buf: VirtualRawVec::new(max_capacity),
len: 0,
}
}
pub fn with_capacity(capacity: usize, max_capacity: usize) -> Self {
Self {
- buf: RawVirtualVec::with_capacity(capacity, max_capacity),
+ buf: VirtualRawVec::with_capacity(capacity, max_capacity),
len: 0,
}
}