rust_3d/is_data_container.rs
1/*
2Copyright 2020 Martin Buck
3
4Permission is hereby granted, free of charge, to any person obtaining a copy
5of this software and associated documentation files (the "Software"),
6to deal in the Software without restriction, including without limitation the
7rights to use, copy, modify, merge, publish, distribute, sublicense,
8and/or sell copies of the Software, and to permit persons to whom the Software
9is furnished to do so, subject to the following conditions:
10
11The above copyright notice and this permission notice shall
12be included all copies or substantial portions of the Software.
13
14THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
19TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
20OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21*/
22
23//! IsDataContainer trait used for data containers allowing for different storage types than using the abstracted type
24
25/// IsDataContainer trait used for data containers allowing for different storage types than using the abstracted type
26pub trait IsDataContainer<T> {
27 /// Should reserve space for n elements of type T
28 fn reserve_d(&mut self, n: usize);
29 /// Should return the number of T elements in the container
30 fn len_d(&self) -> usize;
31 /// Should push a T to the end of the container
32 fn push_d(&mut self, x: T);
33 /// Should return the element at index
34 fn get_d(&self, index: usize) -> T;
35 /// Should set the element at index
36 fn set_d(&mut self, index: usize, x: T);
37}