Ignore:
Timestamp:
Mar 29, 2026, 9:52:51 PM (9 days ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
master
Children:
e6e250d
Parents:
00675ed4
Message:

2nd attempt at harmonizing isOp functions, e.g., isEmpty, to C/C++ form empty

Location:
libcfa/src/collections
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/collections/list.hfa

    r00675ed4 r81ab5eb  
    1010// Created On       : Wed Apr 22 18:00:00 2020
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Mar 27 08:02:56 2026
    13 // Update Count     : 99
     12// Last Modified On : Sun Mar 29 21:20:44 2026
     13// Update Count     : 101
    1414//
    1515
     
    206206        }
    207207
    208         bool isEmpty( dlist( tE, tLinks ) & list ) {
     208        bool isEmpty( dlist( tE, tLinks ) & list ) {            // deprecated
    209209                return empty( list );
    210210        }
     
    413413        // Transfer the "from" list to the end of this sequence; the "from" list is empty after the transfer.
    414414//      void transfer( dlist( tE, tLinks ) & to, dlist( tE, tLinks ) & from ) {
    415 //              if ( isEmpty( from ) ) return;                                  // "from" list empty ?
    416 //              if ( isEmpty( to ) ) {                                                  // "to" list empty ?
     415//              if ( empty( from ) ) return;                                    // "from" list empty ?
     416//              if ( empty( to ) ) {                                                    // "to" list empty ?
    417417//                      root = from.root;
    418418//              } else {                                                                                // "to" list not empty
  • libcfa/src/collections/list2.hfa

    r00675ed4 r81ab5eb  
    1919// Created On       : Wed Apr 22 18:00:00 2020
    2020// Last Modified By : Peter A. Buhr
    21 // Last Modified On : Tue Mar 24 22:20:56 2026
    22 // Update Count     : 8
     21// Last Modified On : Sun Mar 29 21:47:53 2026
     22// Update Count     : 12
    2323//
    2424
     
    206206                };
    207207
    208                 static inline tE * $get_list_origin_addr( dlist(tE, tLinks) & lst ) {
     208                static inline tE * $get_list_origin_addr( dlist(tE, tLinks) & list ) {
    209209                        dlink(tE) & link_from_null = ( * (tE *) 0p )`inner;
    210210                        ptrdiff_t link_offset = (ptrdiff_t) & link_from_null;
    211                         size_t origin_addr = ((size_t) & lst) - link_offset;
     211                        size_t origin_addr = ((size_t) & list) - link_offset;
    212212                        size_t preResult = ORIGIN_TAG_ENABL( origin_addr );
    213213                        return (tE *)preResult;
     
    430430        }
    431431
    432         static inline tE & first( dlist(tE, tLinks) & lst ) {
    433                 verify (&lst != 0p);
    434                 dlink(tE) * firstLnk = lst.next;
     432        static inline tE & first( dlist(tE, tLinks) & list ) {
     433                verify (&list != 0p);
     434                dlink(tE) * firstLnk = list.next;
    435435                if (ORIGIN_TAG_QUERY((size_t)firstLnk)) return * 0p;
    436436                tytagref( tLinks, dlink(tE) ) firstLnkTagged = {*firstLnk};
    437437                return downcast$( firstLnkTagged );
    438438        }
    439         static inline tE & last ( dlist(tE, tLinks) & lst ) {
    440                 verify (&lst != 0p);
    441                 dlink(tE) * lastLnk = lst.prev;
     439        static inline tE & last ( dlist(tE, tLinks) & list ) {
     440                verify (&list != 0p);
     441                dlink(tE) * lastLnk = list.prev;
    442442                if (ORIGIN_TAG_QUERY((size_t)lastLnk)) return * 0p;
    443443                tytagref( tLinks, dlink(tE) ) lastLnkTagged = {*lastLnk};
     
    445445        }
    446446
    447         static inline bool isEmpty( dlist(tE, tLinks) & lst ) {
    448                 verify (&lst != 0p);
    449                 if ( & first(lst) == 0p || & last(lst) == 0p ) {
    450                         verify( & last(lst) == 0p && & last(lst) == 0p );
     447        static inline bool empty( dlist(tE, tLinks) & list ) {
     448                verify (&list != 0p);
     449                if ( & first(list) == 0p || & last(list) == 0p ) {
     450                        verify( & last(list) == 0p && & last(list) == 0p );
    451451                        return true;
    452452                }
    453453                return false;
     454        }
     455
     456        static inline bool isEmpty( dlist(tE, tLinks) & list ) __attribute__ ((deprecated));
     457        static inline bool isEmpty( dlist(tE, tLinks) & list ) {
     458                return empty( list );
    454459        }
    455460
     
    469474        }
    470475
    471         static inline tE & iter( dlist(tE, tLinks) & lst ) {
    472                 tE * origin = $get_list_origin_addr( lst );
     476        static inline tE & iter( dlist(tE, tLinks) & list ) {
     477                tE * origin = $get_list_origin_addr( list );
    473478                return *origin;
    474479        }
     
    538543        // Applies knowledge of tag pattern around head (unknown to optimizer) to reduce runtime tag operations.
    539544
    540         static inline void insert_first( dlist(tE, tLinks) &lst, tE & e ) {
     545        static inline void insert_first( dlist(tE, tLinks) &list, tE & e ) {
    541546                dlink(tE) & linkToInsert = e`inner;
    542547          NOLOOSE(
     
    548553                verify(ORIGIN_TAG_CLEAR((size_t)linkToInsert.next) == (size_t)&linkToInsert);
    549554          )
    550                 dlink(tE) & list_pos_links = lst;
     555                dlink(tE) & list_pos_links = list;
    551556          MAYBE_INSERT_READ_EARLY(
    552557                dlink(tE) & afterLinks = * (dlink(tE) *) ORIGIN_TAG_CLEAR( (size_t) list_pos_links.next );
     
    577582        }
    578583
    579         static inline void insert_last( dlist(tE, tLinks) &lst, tE & e ) {
     584        static inline void insert_last( dlist(tE, tLinks) &list, tE & e ) {
    580585                dlink(tE) & linkToInsert = e`inner;
    581586          NOLOOSE(
     
    587592                verify(ORIGIN_TAG_CLEAR((size_t)linkToInsert.prev) == (size_t)&linkToInsert);
    588593          )
    589                 dlink(tE) & list_pos_links = lst;
     594                dlink(tE) & list_pos_links = list;
    590595          MAYBE_INSERT_READ_EARLY(
    591596                dlink(tE) & beforeLinks = * (dlink(tE) *) ORIGIN_TAG_CLEAR( (size_t) list_pos_links.prev );
     
    630635        }
    631636
    632         static inline tE & remove_first( dlist(tE, tLinks) &lst ) {
    633                 verify (&lst != 0p);
    634                 dlink(tE) & list_links = lst;
     637        static inline tE & remove_first( dlist(tE, tLinks) &list ) {
     638                verify (&list != 0p);
     639                dlink(tE) & list_links = list;
    635640                // call is valid on empty list; when so, list_links.next and after_links.prev have otags set
    636641
     
    657662        }
    658663
    659         static inline tE & remove_last( dlist(tE, tLinks) &lst ) {
    660                 verify (&lst != 0p);
    661                 dlink(tE) & list_links = lst;
     664        static inline tE & remove_last( dlist(tE, tLinks) &list ) {
     665                verify (&list != 0p);
     666                dlink(tE) & list_links = list;
    662667                // call is valid on empty list; when so, list_links.prev and before_links.next have otags set
    663668
     
    684689        }
    685690
    686         static inline tE & try_pop_first( dlist(tE, tLinks) &lst ) {
    687                 tE & first_inlist = first(lst);
     691        static inline tE & try_pop_first( dlist(tE, tLinks) &list ) {
     692                tE & first_inlist = first(list);
    688693                tE & first_item = first_inlist;
    689694                if (&first_item) remove(first_inlist);  // TODO: should it use pop_front?
     
    691696        }
    692697
    693         static inline tE & try_pop_last( dlist(tE, tLinks) &lst ) {
    694                 tE & last_inlist = last(lst);
     698        static inline tE & try_pop_last( dlist(tE, tLinks) &list ) {
     699                tE & last_inlist = last(list);
    695700                tE & last_item = last_inlist;
    696701                if (&last_item) remove(last_inlist);  // TODO: should it use pop_back?
Note: See TracChangeset for help on using the changeset viewer.