1 /* zzektrap.f -- translated by f2c (version 19980913).
2    You must link the resulting object file with the libraries:
3 	-lf2c -lm   (in that order)
4 */
5 
6 #include "f2c.h"
7 
8 /* $Procedure      ZZEKTRAP ( EK tree, append item ) */
zzektrap_(integer * handle,integer * tree,integer * value,integer * key)9 /* Subroutine */ int zzektrap_(integer *handle, integer *tree, integer *value,
10 	 integer *key)
11 {
12     extern /* Subroutine */ int zzektrin_(integer *, integer *, integer *,
13 	    integer *);
14     extern integer zzektrsz_(integer *, integer *);
15 
16 /* $ Abstract */
17 
18 /*     Append an item to a tree.  The key indicating the location of */
19 /*     the new item is returned. */
20 
21 /* $ Disclaimer */
22 
23 /*     THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
24 /*     CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
25 /*     GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
26 /*     ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
27 /*     PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
28 /*     TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
29 /*     WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
30 /*     PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
31 /*     SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
32 /*     SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
33 
34 /*     IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
35 /*     BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
36 /*     LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
37 /*     INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
38 /*     REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
39 /*     REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
40 
41 /*     RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
42 /*     THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
43 /*     CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
44 /*     ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
45 
46 /* $ Required_Reading */
47 
48 /*     EK */
49 
50 /* $ Keywords */
51 
52 /*     EK */
53 /*     PRIVATE */
54 
55 /* $ Declarations */
56 /* $ Brief_I/O */
57 
58 /*     Variable  I/O  Description */
59 /*     --------  ---  -------------------------------------------------- */
60 /*     HANDLE     I   File handle. */
61 /*     TREE       I   Root of tree. */
62 /*     VALUE      I   Value to append. */
63 /*     KEY        O   Key pointing to new value. */
64 
65 /* $ Detailed_Input */
66 
67 /*     HANDLE         is a file handle of an EK open for write access. */
68 
69 /*     TREE           is the root node number of the tree of interest. */
70 
71 /*     VALUE          is an integer value to be appended to the */
72 /*                    specified tree. */
73 
74 /* $ Detailed_Output */
75 
76 /*     KEY            is an absolute key indicating the insertion */
77 /*                    location.  In EK trees, absolute keys are just */
78 /*                    ordinal positions relative to the leftmost element */
79 /*                    of the tree, with the leftmost element having */
80 /*                    position 1. */
81 
82 /* $ Parameters */
83 
84 /*     None. */
85 
86 /* $ Exceptions */
87 
88 /*     1)  If HANDLE is invalid, the error will be diagnosed by routines */
89 /*         called by this routine.  The file will not be modified. */
90 
91 /*     2)  If an I/O error occurs while reading or writing the indicated */
92 /*         file, the error will be diagnosed by routines called by this */
93 /*         routine. */
94 
95 /* $ Files */
96 
97 /*     See the EK Required Reading for a discussion of the EK file */
98 /*     format. */
99 
100 /* $ Particulars */
101 
102 /*     This routine appends a new value to an EK tree; this action is */
103 /*     equivalent to inserting the value at position (NKEYS+1), where */
104 /*     NKEYS is the number of keys in the tree prior to the insertion. */
105 
106 /*     The tree is balanced and satisfies all invariants at the */
107 /*     completion of the appending. */
108 
109 /* $ Examples */
110 
111 /*     See EKBSEG. */
112 
113 /* $ Restrictions */
114 
115 /*     None. */
116 
117 /* $ Literature_References */
118 
119 /*     1)  Knuth, Donald E.  "The Art of Computer Programming, Volume */
120 /*         3/Sorting and Searching" 1973, pp 471-479. */
121 
122 /*         EK trees are closely related to the B* trees described by */
123 /*         Knuth. */
124 
125 /* $ Author_and_Institution */
126 
127 /*     N.J. Bachman   (JPL) */
128 
129 /* $ Version */
130 
131 /* -    SPICELIB Version 1.0.2, 22-SEP-2004 (EDW) */
132 
133 /*        Edited 1.0.1 Version entry to not include */
134 /*        the token used to mark the $Procedure section. */
135 
136 /* -    Beta Version 1.0.1, 14-OCT-1996 (NJB) */
137 
138 /*        $Procedure line was corrected. */
139 
140 /* -    Beta Version 1.0.0, 22-OCT-1995 (NJB) */
141 
142 /* -& */
143 
144 /*     Non-SPICELIB functions */
145 
146     *key = zzektrsz_(handle, tree) + 1;
147     zzektrin_(handle, tree, key, value);
148     return 0;
149 } /* zzektrap_ */
150 
151