[][src]Struct gulkana::DataStructure

pub struct DataStructure<KeyType: Ord + Clone, ItemData: Clone> { /* fields omitted */ }

Struct usd to store data

Methods

impl<KeyType: Ord + Clone, ItemData: Clone> DataStructure<KeyType, ItemData>[src]

pub fn insert(
    &mut self,
    key: &KeyType,
    data: ItemData
) -> Result<(), DBOperationError>
[src]

Inserts data into datastructure

let mut ds = gulkana::new_datastructure::<u32,u32>();
ds.insert(&10,5);
assert!(ds.insert(&10,20).is_err());

Used to insert a link into a datastructure

 let mut ds = gulkana::new_datastructure::<u32,u32>();
 ds.insert(&10,5);
 ds.insert_link(&9,&vec![10]);
 let iter = ds.iter_links(&9).ok().unwrap();
 
 for (i,j) in iter{
     assert!(*j==5);
 }

Overwrites Links with vec shown

 let mut ds = gulkana::new_datastructure::<u32,u32>();
 ds.insert(&10,5);
 ds.insert(&11,6);
 ds.insert_link(&9,&vec![10]);
 ds.overwrite_link(&9,&vec![11]);
 let iter = ds.iter_links(&9).ok().unwrap();
 
 for (_key,data) in iter{
     assert!(*data==6);
 }

pub fn set_data(
    &mut self,
    key: &KeyType,
    data: &ItemData
) -> Result<(), DBOperationError>
[src]

sets data in database

let mut ds = gulkana::new_datastructure::<u32,u32>();
ds.insert(&10,3);
ds.set_data(&10,&5);
assert!(ds.get(&10).ok().unwrap()==&5);

Important traits for DataNodeIter<'a, KeyType, DataType>
pub fn iter_data(&self) -> DataNodeIter<KeyType, ItemData>[src]

Used to iterate through data

Important traits for DataMutIter<'a, KeyType, DataType>
pub fn iter_data_mut(&mut self) -> DataMutIter<KeyType, ItemData>[src]

Iterates through data mutably

let mut ds = gulkana::new_datastructure::<u32,u32>();
ds.insert(&10,3);
for (k,n) in ds.iter_data_mut(){
    *n=5;
}
assert!(ds.get(&10).ok().unwrap()==&5);

pub fn get(&self, key: &KeyType) -> Result<&ItemData, DBOperationError> where
    KeyType: Ord
[src]

gets key from database


let mut ds = gulkana::new_datastructure::<u32,u32>();
ds.insert(&10,5);
let data = ds.get(&10);
assert!(*data.ok().unwrap()==5); 

pub fn get_mut(
    &mut self,
    key: &KeyType
) -> Result<&mut ItemData, DBOperationError>
[src]

Gets data associated with key mutably

let mut ds = gulkana::new_datastructure::<u32,u32>();
ds.insert(&10,5);
let data = ds.get_mut(&10).ok().unwrap();
*data=10;
assert!(ds.get(&10).ok().unwrap()==&10); 

Gets linked nodes

let mut ds = gulkana::new_datastructure::<u32,u32>();
ds.insert(&10,5);
ds.insert(&11,6);
ds.insert_link(&9,&vec![10]);
let v = ds.get_links(&9).ok().unwrap();
assert!(v[0]==10);

Iterates through nodes attached to link

pub fn contains(&self, key: &KeyType) -> bool[src]

Checks if database contains a given key

let mut ds = gulkana::new_datastructure::<u32,u32>();
ds.insert(&10,5);
assert!(ds.contains(&10));
assert!(!ds.contains(&20));

pub fn right_join(
    &self,
    right: &DataStructure<KeyType, ItemData>
) -> Result<DataStructure<KeyType, ItemData>, DBOperationError>
[src]

pub fn to_string(&self) -> Result<String, SerializeError> where
    KeyType: Serialize,
    ItemData: Serialize
[src]

pub fn len(&self) -> usize[src]

Gets number of elements in db

let mut ds = gulkana::new_datastructure::<u32,u32>();
assert!(ds.len()==0);
ds.insert(&20,20);
assert!(ds.len()==1);

Trait Implementations

impl<KeyType: Clone + Ord, ItemData: Clone> Clone for DataStructure<KeyType, ItemData>[src]

impl<'de, KeyType: Ord + Clone, ItemData: Clone> Deserialize<'de> for DataStructure<KeyType, ItemData> where
    KeyType: Deserialize<'de>,
    ItemData: Deserialize<'de>, 
[src]

impl<K: Ord + Display + Clone + Serialize, I: Clone + Serialize> Display for DataStructure<K, I>[src]

impl<KeyType: Eq + Ord + Clone, ItemData: Eq + Clone> Eq for DataStructure<KeyType, ItemData>[src]

impl<KeyType: PartialEq + Ord + Clone, ItemData: PartialEq + Clone> PartialEq<DataStructure<KeyType, ItemData>> for DataStructure<KeyType, ItemData>[src]

impl<KeyType: Ord + Clone, ItemData: Clone> Serialize for DataStructure<KeyType, ItemData> where
    KeyType: Serialize,
    ItemData: Serialize
[src]

impl<KeyType: Ord + Clone, ItemData: Clone> StructuralEq for DataStructure<KeyType, ItemData>[src]

impl<KeyType: Ord + Clone, ItemData: Clone> StructuralPartialEq for DataStructure<KeyType, ItemData>[src]

Auto Trait Implementations

impl<KeyType, ItemData> RefUnwindSafe for DataStructure<KeyType, ItemData> where
    ItemData: RefUnwindSafe,
    KeyType: RefUnwindSafe

impl<KeyType, ItemData> Send for DataStructure<KeyType, ItemData> where
    ItemData: Send,
    KeyType: Send

impl<KeyType, ItemData> Sync for DataStructure<KeyType, ItemData> where
    ItemData: Sync,
    KeyType: Sync

impl<KeyType, ItemData> Unpin for DataStructure<KeyType, ItemData> where
    ItemData: Unpin,
    KeyType: Unpin

impl<KeyType, ItemData> UnwindSafe for DataStructure<KeyType, ItemData> where
    ItemData: RefUnwindSafe + UnwindSafe,
    KeyType: RefUnwindSafe + UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: Deserialize<'de>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,