pub trait ExperienceBufferBase {
type Item;
// Required methods
fn push(&mut self, tr: Self::Item) -> Result<()>;
fn len(&self) -> usize;
}
Expand description
Interface for buffers that store experiences from environments.
This trait defines the basic operations for storing experiences in a buffer. It is typically used by processes that need to sample experiences for training.
§Type Parameters
Item
- The type of experience stored in the buffer
§Examples
ⓘ
struct SimpleBuffer<T> {
items: Vec<T>,
}
impl<T> ExperienceBufferBase for SimpleBuffer<T> {
type Item = T;
fn push(&mut self, tr: T) -> Result<()> {
self.items.push(tr);
Ok(())
}
fn len(&self) -> usize {
self.items.len()
}
}