Changeset 1b20da0 in mainline for kernel/generic/src/adt/avl.c


Ignore:
Timestamp:
2018-02-28T17:52:03Z (7 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
3061bc1
Parents:
df6ded8
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-02-28 17:26:03)
git-committer:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-02-28 17:52:03)
Message:

style: Remove trailing whitespace on non-empty lines, in certain file types.

Command used: tools/srepl '\([^[:space:]]\)\s\+$' '\1' -- *.c *.h *.py *.sh *.s *.S *.ag

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/adt/avl.c

    rdf6ded8 r1b20da0  
    7676                else if (p->key < key)
    7777                        p = p->rgt;
    78                 else 
     78                else
    7979                        return p;
    8080        }
     
    102102         * Iteratively descend to the leftmost leaf in the tree.
    103103         */
    104         while (p->lft != NULL) 
     104        while (p->lft != NULL)
    105105                p = p->lft;
    106106       
     
    156156 * @param t AVL tree.
    157157 * @param newnode New node to be inserted.
    158  */ 
     158 */
    159159void avltree_insert(avltree_t *t, avltree_node_t *newnode)
    160 {       
    161         avltree_node_t *par; 
     160{
     161        avltree_node_t *par;
    162162        avltree_node_t *gpa;
    163163        avltree_node_t *top;
     
    170170        /*
    171171         * Creating absolute key.
    172          */     
     172         */
    173173        key = newnode->key + t->base;
    174174       
     
    223223        if (top->par == NULL) {
    224224                dpc = &t->root;
    225         } else { 
     225        } else {
    226226                if (top->par->lft == top)
    227227                        dpc = &top->par->lft;
     
    255255                         */
    256256                        REBALANCE_INSERT_LL();
    257                 } else { 
     257                } else {
    258258                        /*
    259259                         * LR rotation.
     
    263263                        REBALANCE_INSERT_LR();
    264264                }
    265         } else if (top->balance == 2) { 
     265        } else if (top->balance == 2) {
    266266                par = top->rgt;
    267267                if (par->balance == 1) {
     
    278278                        REBALANCE_INSERT_RL();
    279279                }
    280         } else { 
     280        } else {
    281281                /*
    282282                 * Balance is not broken, insertion is finised.
     
    303303 * @param ro    Read only operation; do not modify any tree pointers. This is
    304304 *              useful for tracking direction via the dir pointer.
    305  * 
     305 *
    306306 * @return      Zero if w became the new root of the tree, otherwise return
    307307 *              non-zero.
     
    313313        if (u->par == NULL) {
    314314                if (!ro)
    315                         t->root = w;   
     315                        t->root = w;
    316316                return 0;
    317         } else {       
     317        } else {
    318318                if (u->par->lft == v) {
    319319                        if (!ro)
     
    362362 * Because multiple identical keys are allowed, the parent pointers are
    363363 * essential during deletion.
    364  * 
     364 *
    365365 * @param t AVL tree structure.
    366366 * @param node Address of the node which will be deleted.
     
    379379                if (node->rgt) {
    380380                        /*
    381                          * Replace the node with its only right son. 
     381                         * Replace the node with its only right son.
    382382                         *
    383383                         * Balance of the right son will be repaired in the
     
    388388                        gpa = cur;
    389389                        dir = RIGHT;
    390                         cur->balance = node->balance; 
     390                        cur->balance = node->balance;
    391391                } else {
    392392                        if (node->par == NULL) {
     
    421421                         * Cutting off of the found node has two cases that
    422422                         * depend on its left son.
    423                          */ 
     423                         */
    424424                        if (cur->lft) {
    425425                                /*
     
    429429                                gpa->par = cur->par;
    430430                                dir = LEFT;
    431                                 gpa->balance = cur->balance; 
     431                                gpa->balance = cur->balance;
    432432                        } else {
    433433                                dir = RIGHT;
     
    436436                        cur->par->rgt = cur->lft;
    437437                        cur->lft = node->lft;
    438                         cur->lft->par = cur; 
    439                 } else { 
     438                        cur->lft->par = cur;
     439                } else {
    440440                        /*
    441441                         * The left son of the node hasn't got a right son. The
     
    443443                         */
    444444                        dir = LEFT;
    445                         gpa = cur; 
     445                        gpa = cur;
    446446                }
    447447                if (node->rgt)
    448                         node->rgt->par = cur; 
     448                        node->rgt->par = cur;
    449449                cur->rgt = node->rgt;
    450450                cur->balance = node->balance;
     
    473473                                 */
    474474                                break;
    475                         } else if (gpa->balance == 2) { 
     475                        } else if (gpa->balance == 2) {
    476476                                /*
    477477                                 * Bad balance, heights of left and right
     
    538538                                                (void) repair(t, par, gpa, par,
    539539                                                    NULL, false);
    540                                                 break; 
     540                                                break;
    541541                                        } else {
    542542                                                par->balance = 0;
     
    559559                                gpa = gpa->par;
    560560                        }
    561                 } else { 
     561                } else {
    562562                        /*
    563563                         * Deletion was made in the right subtree.
     
    605605                                                break;
    606606                                        gpa = cur->par;
    607                                 } else { 
     607                                } else {
    608608                                        /*
    609609                                         * LL rotation.
     
    681681                node = node->lft;
    682682       
    683         avltree_delete(t, node); 
     683        avltree_delete(t, node);
    684684
    685685        return true;
Note: See TracChangeset for help on using the changeset viewer.