diff options
| author | Thien-Thi Nguyen | 2007-08-27 01:44:37 +0000 |
|---|---|---|
| committer | Thien-Thi Nguyen | 2007-08-27 01:44:37 +0000 |
| commit | 85718043eeddf211a3e5b18cc7d31d9a2dd325ad (patch) | |
| tree | 3f35fc10b6639c54684b6a29b380b6f2de7d8020 | |
| parent | 37840380aa33f0aa3f4a5bec772586a6e72741c4 (diff) | |
| download | emacs-85718043eeddf211a3e5b18cc7d31d9a2dd325ad.tar.gz emacs-85718043eeddf211a3e5b18cc7d31d9a2dd325ad.zip | |
Do s/avltree/avl-tree/g. Resulting changed function names:
avl-tree-create, avl-tree-p, avl-tree-compare-function,
avl-tree-empty, avl-tree-enter, avl-tree-delete, avl-tree-member,
avl-tree-map, avl-tree-first, avl-tree-last, avl-tree-copy,
avl-tree-flatten, avl-tree-size, avl-tree-clear.
Make the symbol used for avl-tree-p `AVL-TREE', as well.
| -rw-r--r-- | lisp/emacs-lisp/avl-tree.el | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/lisp/emacs-lisp/avl-tree.el b/lisp/emacs-lisp/avl-tree.el index c0408e2dbd2..58708f77a14 100644 --- a/lisp/emacs-lisp/avl-tree.el +++ b/lisp/emacs-lisp/avl-tree.el | |||
| @@ -43,7 +43,7 @@ | |||
| 43 | ;; * Comments from avltree.el | 43 | ;; * Comments from avltree.el |
| 44 | ;; An AVL tree is a nearly-perfect balanced binary tree. A tree | 44 | ;; An AVL tree is a nearly-perfect balanced binary tree. A tree |
| 45 | ;; consists of two cons cells, the first one holding the tag | 45 | ;; consists of two cons cells, the first one holding the tag |
| 46 | ;; 'AVLTREE in the car cell, and the second one having the tree | 46 | ;; 'AVL-TREE in the car cell, and the second one having the tree |
| 47 | ;; in the car and the compare function in the cdr cell. The tree has | 47 | ;; in the car and the compare function in the cdr cell. The tree has |
| 48 | ;; a dummy node as its root with the real tree in the left pointer. | 48 | ;; a dummy node as its root with the real tree in the left pointer. |
| 49 | ;; | 49 | ;; |
| @@ -441,27 +441,27 @@ | |||
| 441 | ;;; ================================================================ | 441 | ;;; ================================================================ |
| 442 | ;;; The public functions which operate on AVL trees. | 442 | ;;; The public functions which operate on AVL trees. |
| 443 | 443 | ||
| 444 | (defun avltree-create (compare-function) | 444 | (defun avl-tree-create (compare-function) |
| 445 | "Create an empty avl tree. | 445 | "Create an empty avl tree. |
| 446 | COMPARE-FUNCTION is a function which takes two arguments, A and B, | 446 | COMPARE-FUNCTION is a function which takes two arguments, A and B, |
| 447 | and returns non-nil if A is less than B, and nil otherwise." | 447 | and returns non-nil if A is less than B, and nil otherwise." |
| 448 | (cons 'AVLTREE | 448 | (cons 'AVL-TREE |
| 449 | (cons (elib-avl-node-create nil nil nil 0) | 449 | (cons (elib-avl-node-create nil nil nil 0) |
| 450 | compare-function))) | 450 | compare-function))) |
| 451 | 451 | ||
| 452 | (defun avltree-p (obj) | 452 | (defun avl-tree-p (obj) |
| 453 | "Return t if OBJ is an avl tree, nil otherwise." | 453 | "Return t if OBJ is an avl tree, nil otherwise." |
| 454 | (eq (car-safe obj) 'AVLTREE)) | 454 | (eq (car-safe obj) 'AVL-TREE)) |
| 455 | 455 | ||
| 456 | (defun avltree-compare-function (tree) | 456 | (defun avl-tree-compare-function (tree) |
| 457 | "Return the comparision function for the avl tree TREE." | 457 | "Return the comparision function for the avl tree TREE." |
| 458 | (elib-avl-cmpfun tree)) | 458 | (elib-avl-cmpfun tree)) |
| 459 | 459 | ||
| 460 | (defun avltree-empty (tree) | 460 | (defun avl-tree-empty (tree) |
| 461 | "Return t if TREE is emtpy, otherwise return nil." | 461 | "Return t if TREE is emtpy, otherwise return nil." |
| 462 | (null (elib-avl-root tree))) | 462 | (null (elib-avl-root tree))) |
| 463 | 463 | ||
| 464 | (defun avltree-enter (tree data) | 464 | (defun avl-tree-enter (tree data) |
| 465 | "In the avl tree TREE insert DATA. | 465 | "In the avl tree TREE insert DATA. |
| 466 | Return DATA." | 466 | Return DATA." |
| 467 | (elib-avl-do-enter (elib-avl-cmpfun tree) | 467 | (elib-avl-do-enter (elib-avl-cmpfun tree) |
| @@ -470,7 +470,7 @@ Return DATA." | |||
| 470 | data) | 470 | data) |
| 471 | data) | 471 | data) |
| 472 | 472 | ||
| 473 | (defun avltree-delete (tree data) | 473 | (defun avl-tree-delete (tree data) |
| 474 | "From the avl tree TREE, delete DATA. | 474 | "From the avl tree TREE, delete DATA. |
| 475 | Return the element in TREE which matched DATA, nil if no element matched." | 475 | Return the element in TREE which matched DATA, nil if no element matched." |
| 476 | (elib-avl-do-delete (elib-avl-cmpfun tree) | 476 | (elib-avl-do-delete (elib-avl-cmpfun tree) |
| @@ -478,9 +478,9 @@ Return the element in TREE which matched DATA, nil if no element matched." | |||
| 478 | 0 | 478 | 0 |
| 479 | data)) | 479 | data)) |
| 480 | 480 | ||
| 481 | (defun avltree-member (tree data) | 481 | (defun avl-tree-member (tree data) |
| 482 | "Return the element in the avl tree TREE which matches DATA. | 482 | "Return the element in the avl tree TREE which matches DATA. |
| 483 | Matching uses the compare function previously specified in `avltree-create' | 483 | Matching uses the compare function previously specified in `avl-tree-create' |
| 484 | when TREE was created. | 484 | when TREE was created. |
| 485 | 485 | ||
| 486 | If there is no such element in the tree, the value is nil." | 486 | If there is no such element in the tree, the value is nil." |
| @@ -501,7 +501,7 @@ If there is no such element in the tree, the value is nil." | |||
| 501 | (elib-node-data node) | 501 | (elib-node-data node) |
| 502 | nil))) | 502 | nil))) |
| 503 | 503 | ||
| 504 | (defun avltree-map (__map-function__ tree) | 504 | (defun avl-tree-map (__map-function__ tree) |
| 505 | "Apply MAP-FUNCTION to all elements in the avl tree TREE." | 505 | "Apply MAP-FUNCTION to all elements in the avl tree TREE." |
| 506 | (elib-avl-mapc | 506 | (elib-avl-mapc |
| 507 | (function (lambda (node) | 507 | (function (lambda (node) |
| @@ -510,7 +510,7 @@ If there is no such element in the tree, the value is nil." | |||
| 510 | (elib-node-data node))))) | 510 | (elib-node-data node))))) |
| 511 | (elib-avl-root tree))) | 511 | (elib-avl-root tree))) |
| 512 | 512 | ||
| 513 | (defun avltree-first (tree) | 513 | (defun avl-tree-first (tree) |
| 514 | "Return the first element in TREE, or nil if TREE is empty." | 514 | "Return the first element in TREE, or nil if TREE is empty." |
| 515 | (let ((node (elib-avl-root tree))) | 515 | (let ((node (elib-avl-root tree))) |
| 516 | (if node | 516 | (if node |
| @@ -520,7 +520,7 @@ If there is no such element in the tree, the value is nil." | |||
| 520 | (elib-node-data node)) | 520 | (elib-node-data node)) |
| 521 | nil))) | 521 | nil))) |
| 522 | 522 | ||
| 523 | (defun avltree-last (tree) | 523 | (defun avl-tree-last (tree) |
| 524 | "Return the last element in TREE, or nil if TREE is empty." | 524 | "Return the last element in TREE, or nil if TREE is empty." |
| 525 | (let ((node (elib-avl-root tree))) | 525 | (let ((node (elib-avl-root tree))) |
| 526 | (if node | 526 | (if node |
| @@ -530,15 +530,15 @@ If there is no such element in the tree, the value is nil." | |||
| 530 | (elib-node-data node)) | 530 | (elib-node-data node)) |
| 531 | nil))) | 531 | nil))) |
| 532 | 532 | ||
| 533 | (defun avltree-copy (tree) | 533 | (defun avl-tree-copy (tree) |
| 534 | "Return a copy of the avl tree TREE." | 534 | "Return a copy of the avl tree TREE." |
| 535 | (let ((new-tree (avltree-create | 535 | (let ((new-tree (avl-tree-create |
| 536 | (elib-avl-cmpfun tree)))) | 536 | (elib-avl-cmpfun tree)))) |
| 537 | (elib-node-set-left (elib-avl-dummyroot new-tree) | 537 | (elib-node-set-left (elib-avl-dummyroot new-tree) |
| 538 | (elib-avl-do-copy (elib-avl-root tree))) | 538 | (elib-avl-do-copy (elib-avl-root tree))) |
| 539 | new-tree)) | 539 | new-tree)) |
| 540 | 540 | ||
| 541 | (defun avltree-flatten (tree) | 541 | (defun avl-tree-flatten (tree) |
| 542 | "Return a sorted list containing all elements of TREE." | 542 | "Return a sorted list containing all elements of TREE." |
| 543 | (nreverse | 543 | (nreverse |
| 544 | (let ((treelist nil)) | 544 | (let ((treelist nil)) |
| @@ -548,7 +548,7 @@ If there is no such element in the tree, the value is nil." | |||
| 548 | (elib-avl-root tree)) | 548 | (elib-avl-root tree)) |
| 549 | treelist))) | 549 | treelist))) |
| 550 | 550 | ||
| 551 | (defun avltree-size (tree) | 551 | (defun avl-tree-size (tree) |
| 552 | "Return the number of elements in TREE." | 552 | "Return the number of elements in TREE." |
| 553 | (let ((treesize 0)) | 553 | (let ((treesize 0)) |
| 554 | (elib-avl-mapc (function (lambda (data) | 554 | (elib-avl-mapc (function (lambda (data) |
| @@ -557,11 +557,11 @@ If there is no such element in the tree, the value is nil." | |||
| 557 | (elib-avl-root tree)) | 557 | (elib-avl-root tree)) |
| 558 | treesize)) | 558 | treesize)) |
| 559 | 559 | ||
| 560 | (defun avltree-clear (tree) | 560 | (defun avl-tree-clear (tree) |
| 561 | "Clear the avl tree TREE." | 561 | "Clear the avl tree TREE." |
| 562 | (elib-node-set-left (elib-avl-dummyroot tree) nil)) | 562 | (elib-node-set-left (elib-avl-dummyroot tree) nil)) |
| 563 | 563 | ||
| 564 | (provide 'avl-tree) | 564 | (provide 'avl-tree) |
| 565 | 565 | ||
| 566 | ;; arch-tag: 47e26701-43c9-4222-bd79-739eac6357a9 | 566 | ;; arch-tag: 47e26701-43c9-4222-bd79-739eac6357a9 |
| 567 | ;;; avltree.el ends here | 567 | ;;; avl-tree.el ends here |