Changeset 8d1ad36 for libcfa/src/containers/list2.hfa
- Timestamp:
- May 11, 2021, 9:14:26 PM (3 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 7d51ef8
- Parents:
- 4ab767a
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/containers/list2.hfa
r4ab767a r8d1ad36 17 17 18 18 #include <assert.h> 19 20 forall( T & ) struct tag {};21 #define ttag(T) ((tag(T)){})22 #define ztag(n) ttag(Z(n))23 19 24 20 extern "C" { … … 191 187 } 192 188 189 static inline bool ?`isEmpty( dlist(tE, tLinks) & lst ) { 190 tE * firstPtr = lst.next; 191 if (ORIGIN_TAG_QUERY((size_t)firstPtr)) firstPtr = 0p; 192 return firstPtr == 0p; 193 } 194 193 195 static inline int ?!=?( const diref(tE, tLinks) & list_pos, zero_t ) { 194 196 tE & list_pos_elem = list_pos; … … 229 231 } 230 232 233 static inline bool ?`hasNext( diref(tE, tLinks) refx ) { 234 return refx`moveNext; 235 } 236 237 static inline bool ?`hasPrev( diref(tE, tLinks) refx ) { 238 return refx`movePrev; 239 } 240 241 static inline diref(tE, tLinks) ?`next( diref(tE, tLinks) refx ) { 242 if( refx`moveNext ) return refx; 243 tE && ref_inner = refx; 244 & ref_inner = 0p; 245 return refx; 246 } 247 248 static inline diref(tE, tLinks) ?`prev( diref(tE, tLinks) refx ) { 249 if( refx`movePrev ) return refx; 250 tE && ref_inner = refx; 251 & ref_inner = 0p; 252 return refx; 253 } 254 231 255 static inline void insert_first( dlist(tE, tLinks) &lst, tE & e ) { 232 256 insert_after(lst`elems, e); … … 235 259 static inline void insert_last( dlist(tE, tLinks) &lst, tE & e ) { 236 260 insert_before(lst`elems, e); 261 } 262 263 static inline tE & try_pop_front( dlist(tE, tLinks) &lst ) { 264 diref(tE, tLinks) first_inlist = lst`first; 265 tE & first_item = first_inlist; 266 if (&first_item) remove(first_inlist); 267 return first_item; 268 } 269 270 static inline tE & try_pop_back( dlist(tE, tLinks) &lst ) { 271 diref(tE, tLinks) last_inlist = lst`last; 272 tE & last_item = last_inlist; 273 if (&last_item) remove(last_inlist); 274 return last_item; 237 275 } 238 276 … … 297 335 return ref_dird`movePrev; 298 336 } 299 337 static inline bool ?`hasNext( tE & ref ) { 338 diref(tE, tE) ref_dird = { ref }; 339 return ref_dird`hasNext; 340 } 341 static inline bool ?`hasPrev( tE & ref ) { 342 diref(tE, tE) ref_dird = { ref }; 343 return ref_dird`hasPrev; 344 } 345 static inline tE & ?`next( tE & ref ) { 346 diref(tE, tE) ref_dird = { ref }; 347 diref(tE, tE) rslt = ref_dird`next; 348 return rslt; 349 } 350 static inline tE & ?`prev( tE & ref ) { 351 diref(tE, tE) ref_dird = { ref }; 352 diref(tE, tE) rslt = ref_dird`prev; 353 return rslt; 354 } 300 355 }
Note: See TracChangeset
for help on using the changeset viewer.