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
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
//! 2021.6.30; This module is not finished yet.
//!

use super::TreeHandle;

pub enum GenError {
    WillOverflow,
    IllegalRate,
}

pub type Bone = Vec<bool>;
pub type Result<T> = std::result::Result<T, GenError>;

pub struct BoneBuilder;

pub enum Direction {
    OneWayLeft,
    OneWayRight,
    Random,
}

impl BoneBuilder {
    pub fn fixed_len_one(tree_len: u32) -> Bone {
        unimplemented!()
    }

    pub fn fixed_len_drained(tree_len: u32) -> Result<Vec<Bone>> {
        unimplemented!()
    }

    pub fn fixed_len_drained_lte(tree_len_ub: u32) -> Result<Vec<Bone>> {
        unimplemented!()
    }

    pub fn fixed_len_rate(rate: f64) -> Result<Vec<Bone>> {
        unimplemented!()
    }

    pub fn fixed_len_nodup(tree_len: u32, tree_num: u32) -> Result<Vec<Bone>> {
        unimplemented!()
    }

    pub fn linked_list(tree_len: u32, d: Direction) -> Bone {
        unimplemented!()
    }

    pub fn linked_list_custom(tree_len: u32, random_len: u32) -> (Bone, Bone, Vec<Bone>) {
        unimplemented!()
    }

    pub fn heap(tree_len: u32) -> Bone {
        unimplemented!()
    }

    pub fn heap_lte(tree_len_ub: u32) -> Vec<Bone> {
        unimplemented!()
    }

    pub fn pyramid(height: u8) -> Result<Bone> {
        unimplemented!()
    }

    pub fn pyramid_lte(height_ub: u8) -> Result<Bone> {
        unimplemented!()
    }

    pub fn complete(nonleaf_len: u32) -> Result<Bone> {
        unimplemented!()
    }
}

#[derive(Eq, PartialEq, Debug, Copy, Clone)]
pub enum Distribution {
    Sorted,
    UniqueSorted,
    Uni(Option<i32>),
    Random,
}

#[derive(Eq, PartialEq, Debug, Copy, Clone)]
pub enum SeqRange {
    Positive,
    NonNegative,
    NonPositive,
    Negative,
    Z,
}

#[derive(Debug)]
struct ValueRenderer<'a> {
    data: &'a [Bone],
    pub dist: Distribution,
    pub r: SeqRange,
}

impl<'a> ValueRenderer<'a> {
    #[inline]
    pub fn new(data: &'a [Bone]) -> Self {
        Self {
            data,
            dist: Distribution::Random,
            r: SeqRange::Z,
        }
    }

    #[inline]
    pub fn from(data: &'a [Bone], dist: Distribution, r: SeqRange) -> Self {
        Self { data, dist, r }
    }

    #[inline]
    pub fn reset(&'a mut self, b: &'a [Bone]) {
        self.data = b;
    }

    pub fn get(&self) -> Vec<TreeHandle> {
        unimplemented!()
    }
}

// #[derive(Debug, Clone)]
// pub enum Subset {
//     Default,
//     // of len *
//     FixedLen(u32),
//     // of height *
//     FixedHeight(u32),
//     // of height no more than *
//     SingleList(u32),
//     // of height no more than *
//     FullShape(u8),
//     // of len no more than *
//     HeapShape(u32),
//     // of len no more than *
//     CompleteShape(u32),
//     // of shapes specified in *
//     Shape(Vec<Bone>),
// }
//
// #[derive(Debug, Copy, Clone)]
// pub enum StopWhen {
//     StructureDrained,
//     TriedTimes(u32),
//     TimesUp(Duration),
//     GotNums(u32),
//     GotRate(f64),
// }
//
// #[derive(Debug, Copy, Clone)]
// pub enum ValueDistribution {
//     Sorted,
//     UniqueSorted,
//     Unique(Option<i32>),
//     Random,
// }
//
// #[derive(Debug)]
// pub struct GenOptions {
//     subset: Subset,
//     stop_when: StopWhen,
//     distribution: ValueDistribution,
//     range: Option<HashSet<i32>>,
//     timeout: Option<Duration>,
// }
//
// #[derive(Debug, Eq, PartialEq)]

//
// impl GenOptions {
//     pub fn new() -> GenOptions {
//         Self {
//             subset: Subset::Default,
//             stop_when: StopWhen::GotNums(4096),
//             distribution: ValueDistribution::Random,
//             range: None,
//             timeout: None,
//         }
//     }
//
//     #[inline]
//     pub fn subset(mut self, s: Subset) -> Self {
//         self.subset = s;
//         self
//     }
//
//     #[inline]
//     pub fn stop_when(mut self, when: StopWhen) -> Self {
//         self.stop_when = when;
//         self
//     }
//
//     #[inline]
//     pub fn distribution(mut self, d: ValueDistribution) -> Self {
//         self.distribution = d;
//         self
//     }
//
//     #[inline]
//     pub fn range(mut self, r: HashSet<i32>) -> Self {
//         self.range = Some(r);
//         self
//     }
//
//     #[inline]
//     pub fn timeout(mut self, d: Duration) -> Self {
//         self.timeout = Some(d);
//         self
//     }
//
//     /* priv */ fn gen(self) -> Result<Vec<TreeHandle>, GenError> {
//         unimplemented!()
//     }
//
//     /* priv */ unsafe fn gen_everything_unchecked(self) -> Vec<TreeHandle> {
//         unimplemented!()
//     }
//
//     pub fn test(&self) -> Result<(), GenError> {
//         if let Subset::FixedHeight(u) = self.subset{
//             if n > 32{
//                 return Err(GenError::WillOverflowU32(self.subset.clone(), self.stop_when))
//             }
//         }
//
//         Ok(())
//     }
// }
//
// pub struct Engine(Vec<GenOptions>);
//
// impl Engine {
//     pub fn new() -> Self {
//         unimplemented!()
//     }
//
//     pub fn with_capacity(cap: usize) -> Self {
//         unimplemented!()
//     }
//
//     pub fn add(opt: GenOptions) {
//         unimplemented!()
//     }
//
//     pub fn run(self) -> Result<TreeSetFilter, GenError> {
//         let mut v = vec![2, 3, 4];
//         unimplemented!()
//     }
// }
//
// pub struct TreeSetFilter(Vec<TreeHandle>);
//
// impl TreeSetFilter {
//     #[inline]
//     pub fn sort_by_cached_key_and_then_dedup_by<K, KeyCluster, Dedup>
//     (&mut self, f: KeyCluster, mut d: Dedup)
//         where
//             K: Ord,
//             KeyCluster: FnMut(&TreeHandle) -> K,
//             Dedup: FnMut(&mut TreeHandle, &mut TreeHandle) -> bool {
//         self.0.sort_by_cached_key(f);
//         self.0.dedup_by(d);
//     }
//
//     #[inline]
//     pub fn get(self) -> Vec<TreeHandle> { self.0 }
// }
//
// pub trait Renderer {
//     #[inline]
//     fn render(t: TreeHandle) -> String;
// }
//
// pub struct LeetcodeTreeFormatRenderer;
//
// impl Renderer for LeetcodeTreeFormatRenderer {
//     #[inline]
//     fn render(t: TreeHandle) -> String {
//         super::T(t).to_leetcode_raw()
//     }
// }
//