Changeset 4f22d0c3 in mainline


Ignore:
Timestamp:
2018-07-05T21:41:23Z (6 years ago)
Author:
Dzejrou <dzejrou@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
cf573ec
Parents:
27f1bc0
git-author:
Dzejrou <dzejrou@…> (2018-05-13 23:27:05)
git-committer:
Dzejrou <dzejrou@…> (2018-07-05 21:41:23)
Message:

cpp: fixed end(), it was broken because of the change to node lists for multi tables

Location:
uspace/lib/cpp/include/internal
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/cpp/include/internal/rbtree.hpp

    r27f1bc0 r4f22d0c3  
    125125            iterator end()
    126126            {
    127                 return iterator{find_largest_(), true};
     127                /**
     128                 * In case we have lists of nodes
     129                 * we need to get the actual end
     130                 * from the largest node.
     131                 */
     132                auto res = find_largest_();
     133                if (res)
     134                    return iterator{res->get_end(), true};
     135                else
     136                    return iterator{res, true};
    128137            }
    129138
     
    160169            const_iterator cend() const
    161170            {
    162                 return const_iterator{find_largest_(), true};
     171                auto res = find_largest_();
     172                if (res)
     173                    return const_iterator{res->get_end(), true};
     174                else
     175                    return const_iterator{res, true};
    163176            }
    164177
  • uspace/lib/cpp/include/internal/rbtree_node.hpp

    r27f1bc0 r4f22d0c3  
    401401            }
    402402
     403            rbtree_single_node* get_end()
     404            {
     405                return this;
     406            }
     407
     408            const rbtree_single_node* get_end() const
     409            {
     410                return this;
     411            }
     412
    403413            ~rbtree_single_node()
    404414            {
     
    428438            rbtree_multi_node(Args&&... args)
    429439                : value{forward<Args>(args)...}, color{rbcolor::red},
    430                   parent_{}, left_{}, right_{}, next_{}, first_{this}
    431             { /* DUMMY BODY */ }
     440                  parent_{}, left_{}, right_{}, next_{}, first_{}
     441            {
     442                first_ = this;
     443            }
    432444
    433445            rbtree_multi_node* parent() const
     
    615627            }
    616628
     629            rbtree_multi_node* get_end()
     630            {
     631                return const_cast<rbtree_multi_node*>(
     632                    const_cast<const rbtree_multi_node*>(this)->get_end()
     633                );
     634            }
     635
     636            const rbtree_multi_node* get_end() const
     637            {
     638                if (!next_)
     639                    return this;
     640                else
     641                {
     642                    auto tmp = next_;
     643                    while (tmp->next_)
     644                        tmp = tmp->next_;
     645
     646                    return tmp;
     647                }
     648            }
     649
    617650            ~rbtree_multi_node()
    618651            {
     
    620653                if (left_)
    621654                    delete left_;
    622                 if (right)
     655                if (right_)
    623656                    delete right_;
    624657
Note: See TracChangeset for help on using the changeset viewer.