1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
use std::cmp::Ordering;

use versatile_data::Data;

pub struct Collection{
    id:u32
    ,data:Data
}
impl Collection{
    pub fn new(id:u32,data:Data)->Collection{
        Collection{
            id
            ,data
        }
    }
    pub fn id(&self)->u32{
        self.id
    }
    pub fn data(&self)->&Data{
        &self.data
    }
    pub fn data_mut(&mut self)->&mut Data{
        &mut self.data
    }
}

#[derive(Clone,Copy,Default,Debug)]
pub struct CollectionRow{
    collection_id:u32
    ,row:u32
}
impl PartialOrd for CollectionRow {
    fn partial_cmp(&self, other: &CollectionRow) -> Option<Ordering> {
        Some(self.cmp(other))
    }
}
impl Ord for CollectionRow{
    fn cmp(&self,other:&CollectionRow)->Ordering{
        if self.collection_id==other.collection_id{
            if self.row==other.row{
                Ordering::Equal
            }else if self.row>other.row{
                Ordering::Greater
            }else{
                Ordering::Less
            }
        }else if self.collection_id>other.collection_id{
            Ordering::Greater
        }else{
            Ordering::Less
        }
    }
}
impl PartialEq for CollectionRow {
    fn eq(&self, other: &CollectionRow) -> bool {
        self.collection_id == other.collection_id && self.row == other.row
    }
}
impl Eq for CollectionRow {}

impl CollectionRow{
    pub fn new(
        collection_id:u32
        ,row:u32
    )->CollectionRow{
        CollectionRow{
            collection_id
            ,row
        }
    }
    pub fn collection_id(&self)->u32{
        self.collection_id
    }
    pub fn row(&self)->u32{
        self.row
    }
}