Skip to main content

ChunkedVec

Struct ChunkedVec 

Source
pub struct ChunkedVec<T> {
    chunks: Vec<Vec<T>>,
    len: usize,
}
Expand description

固定長の塊を並べた追記専用の配列(索引で引ける)。

【2026-10-19】YouTube の視聴ページの kevlar_base(10.8MB、約 320 万トークン)で、 Vec<Token> が倍々に伸びて 128MB の連続領域を要求し、ヒープ(512MB、使用 325MB)で 確保に失敗していた。塊(CHUNK 個)ごとに確保すれば、大きな連続領域も、伸長時の 旧・新の二重持ちも要らない。

Fields§

§chunks: Vec<Vec<T>>§len: usize

Implementations§

Source§

impl<T> ChunkedVec<T>

Source

const SHIFT: usize = 14

Source

const CHUNK: usize

Source

pub fn new() -> Self

Source

pub fn push(&mut self, v: T)

Source

pub fn len(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Source

pub fn get(&self, i: usize) -> Option<&T>

Source

pub fn iter_from(&self, from: usize) -> impl Iterator<Item = (usize, &T)>

位置 from 以降を(位置, 要素)で順に返す。

Trait Implementations§

Source§

impl<T> Default for ChunkedVec<T>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<T> Freeze for ChunkedVec<T>

§

impl<T> RefUnwindSafe for ChunkedVec<T>
where T: RefUnwindSafe,

§

impl<T> Send for ChunkedVec<T>
where T: Send,

§

impl<T> Sync for ChunkedVec<T>
where T: Sync,

§

impl<T> Unpin for ChunkedVec<T>
where T: Unpin,

§

impl<T> UnsafeUnpin for ChunkedVec<T>

§

impl<T> UnwindSafe for ChunkedVec<T>
where T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.