StockPool

Struct StockPool 

Source
pub struct StockPool<T> { /* private fields */ }
Expand description

Design a high-performance stock pool, where all data is stored in arrays, and data is accessed via array indices; this index is converted from the stock code; 4 arrays, one for Shanghai Main Board stocks, one for Shenzhen Main Board stocks, one for ChiNext stocks; and one for STAR Market stocks; The length of each array is fixed, determined by the number of stocks in the A-share market; for example, if the number of Shanghai Main Board stocks is 1500, the array length is 1500;

设计一个高性能股票池, 数据全部以数组的形式存储, 通过数组的下标来获取数据; 此下标是股票代码转换而来; 4个数组, 一个存储上海主板股票, 一个存储深圳主板股票, 一个存储创业板股票; 还有一个数组存储科创板股票; 每个数组的长度是固定的, 都根据A股市场的股票数量来确定; 例如上海主板股票数量是1500, 则数组的长度是1500;

Implementations§

Source§

impl<T: Default> StockPool<T>

Source

pub fn new_default() -> StockPool<T>

Create a new StockPool with default values 创建一个带有默认值的 StockPool

Source§

impl<T> StockPool<T>

Source

pub fn new_empty() -> StockPool<T>

Source

pub fn len(&self) -> usize

Get the number of items in the pool 获取池中的项目数量

Source

pub fn all_items(&self) -> Vec<&T>

Get all items in the pool 获取池中的所有项目

Source

pub fn is_empty(&self, i7: i32) -> bool

Check if the item at the given index is empty 检查给定索引处的项目是否为空

Source

pub fn get(&self, i7: i32) -> Option<&T>

获取股票数据; 股票代码是7位数字, 1开头说明是上海票, 2开头说明是深圳票; 其它6位数与常规股票代码一样;

Source

pub fn get_unchecked(&self, i7: i32) -> &T

Source

pub fn get_mut(&self, i7: i32) -> Option<&mut T>

Source

pub fn insert(&self, i7: i32, val: T) -> Option<Box<T>>

Source

pub fn remove(&self, i7: i32) -> Option<Box<T>>

Trait Implementations§

Source§

impl<T: Default> Index<i32> for StockPool<T>

Source§

type Output = T

The returned type after indexing.
Source§

fn index(&self, i7: i32) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<T: Default> IndexMut<i32> for StockPool<T>

Source§

fn index_mut(&mut self, i7: i32) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl<T: Send> Send for StockPool<T>

Source§

impl<T: Sync> Sync for StockPool<T>

Auto Trait Implementations§

§

impl<T> Freeze for StockPool<T>

§

impl<T> !RefUnwindSafe for StockPool<T>

§

impl<T> Unpin for StockPool<T>

§

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

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

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

§

type Error = Infallible

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

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

Performs the conversion.
§

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

§

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

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

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

Performs the conversion.