1#[ allow( clippy::wildcard_imports ) ]
9use crate::*;
10#[ allow( unused ) ]
11use collection_tools::BinaryHeap;
12
13impl< E > Collection for BinaryHeap< E >
14{
15 type Entry = E;
16 type Val = E;
17
18 #[ inline( always ) ]
19 fn entry_to_val( e : Self::Entry ) -> Self::Val
20 {
21 e
22 }
23
24}
25
26impl< E > CollectionAdd for BinaryHeap< E >
27where
28 E : Ord
29{
30
31 #[ inline( always ) ]
32 fn add( &mut self, e : Self::Entry ) -> bool
33 {
34 self.push( e );
35 true
36 }
37
38}
39
40impl< E > CollectionAssign for BinaryHeap< E >
41where
42 E : Ord
43{
44 #[ inline( always ) ]
45 fn assign< Elements >( &mut self, elements : Elements ) -> usize
46 where
47 Elements : IntoIterator< Item = Self::Entry >
48 {
49 let initial_len = self.len();
50 self.extend( elements );
51 self.len() - initial_len
52 }
53
54}
55
56impl< E > CollectionValToEntry< E > for BinaryHeap< E >
57{
58 type Entry = E;
59 #[ inline( always ) ]
60 fn val_to_entry( val : E ) -> Self::Entry
61 {
62 val
63 }
64}
65
66impl< E > Storage
69for BinaryHeap< E >
70where
71 E : Ord
72{
73 type Preformed = BinaryHeap< E >;
74}
75
76impl< E > StoragePreform
77for BinaryHeap< E >
78where
79 E : Ord
80{
81 fn preform( self ) -> Self::Preformed
82 {
83 self
84 }
85}
86
87#[ derive( Debug, Default ) ]
102pub struct BinaryHeapDefinition< E, Context, Formed, End >
103where
104 E : Ord,
105 End : FormingEnd< BinaryHeapDefinitionTypes< E, Context, Formed > >,
106{
107 _phantom : core::marker::PhantomData< ( E, Context, Formed, End ) >,
108}
109
110impl< E, Context, Formed, End > FormerDefinition
111for BinaryHeapDefinition< E, Context, Formed, End >
112where
113 E : Ord,
114 End : FormingEnd< BinaryHeapDefinitionTypes< E, Context, Formed > >,
115{
116 type Storage = BinaryHeap< E >;
117 type Context = Context;
118 type Formed = Formed;
119
120 type Types = BinaryHeapDefinitionTypes< E, Context, Formed >;
121 type End = End;
122}
123
124#[ derive( Debug, Default ) ]
138pub struct BinaryHeapDefinitionTypes< E, Context = (), Formed = BinaryHeap< E > >
139{
140 _phantom : core::marker::PhantomData< ( E, Context, Formed ) >,
141}
142
143impl< E, Context, Formed > FormerDefinitionTypes
144for BinaryHeapDefinitionTypes< E, Context, Formed >
145where
146 E : Ord
147{
148 type Storage = BinaryHeap< E >;
149 type Context = Context;
150 type Formed = Formed;
151}
152
153impl< E, Context, Formed > FormerMutator
156for BinaryHeapDefinitionTypes< E, Context, Formed >
157where
158 E : Ord
159{
160}
161
162impl< E, Definition > EntityToFormer< Definition >
165for BinaryHeap< E >
166where
167 E : Ord,
168 Definition : FormerDefinition
169 <
170 Storage = BinaryHeap< E >,
171 Types = BinaryHeapDefinitionTypes
172 <
173 E,
174 < Definition as definition::FormerDefinition >::Context,
175 < Definition as definition::FormerDefinition >::Formed,
176 >,
177 >,
178 Definition::End : forming::FormingEnd< Definition::Types >,
179{
180 type Former = BinaryHeapFormer< E, Definition::Context, Definition::Formed, Definition::End >;
181}
182
183impl< E > crate::EntityToStorage
184for BinaryHeap< E >
185{
186 type Storage = BinaryHeap< E >;
187}
188
189impl< E, Context, Formed, End > crate::EntityToDefinition< Context, Formed, End >
190for BinaryHeap< E >
191where
192 E : Ord,
193 End : crate::FormingEnd< BinaryHeapDefinitionTypes< E, Context, Formed > >,
194{
195 type Definition = BinaryHeapDefinition< E, Context, Formed, End >;
196 type Types = BinaryHeapDefinitionTypes< E, Context, Formed >;
197}
198
199impl< E, Context, Formed > crate::EntityToDefinitionTypes< Context, Formed >
200for BinaryHeap< E >
201where
202 E : Ord
203{
204 type Types = BinaryHeapDefinitionTypes< E, Context, Formed >;
205}
206
207pub type BinaryHeapFormer< E, Context, Formed, End > =
221CollectionFormer::< E, BinaryHeapDefinition< E, Context, Formed, End > >;
222
223pub trait BinaryHeapExt< E > : sealed::Sealed
233where
234 E : Ord
235{
236 fn former() -> BinaryHeapFormer< E, (), BinaryHeap< E >, ReturnStorage >;
238}
239
240impl< E > BinaryHeapExt< E > for BinaryHeap< E >
241where
242 E : Ord
243{
244 #[ allow( clippy::default_constructed_unit_structs ) ]
245 fn former() -> BinaryHeapFormer< E, (), BinaryHeap< E >, ReturnStorage >
246 {
247 BinaryHeapFormer::< E, (), BinaryHeap< E >, ReturnStorage >::new( ReturnStorage::default() )
248 }
249}
250
251mod sealed
252{
253 pub trait Sealed {}
254 impl< E > Sealed for super::BinaryHeap< E > {}
255}