1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<!--Converted with LaTeX2HTML 98.1p1 release (March 2nd, 1998)
originally by Nikos Drakos (nikos@cbl.leeds.ac.uk), CBLU, University of Leeds
* revised and updated by: Marcus Hennecke, Ross Moore, Herb Swan
* with significant contributions from:
Jens Lippmann, Marek Rouchal, Martin Wilck and others -->
<HTML>
<HEAD>
<TITLE>Generated Functions</TITLE>
<META NAME="description" CONTENT="Generated Functions">
<META NAME="keywords" CONTENT="tpman">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<LINK REL="STYLESHEET" HREF="tpman.css">
<LINK REL="next" HREF="node18.html">
<LINK REL="previous" HREF="node16.html">
<LINK REL="up" HREF="node15.html">
<LINK REL="next" HREF="node18.html">
</HEAD>
<BODY >
<!--Navigation Panel-->
<A NAME="tex2html335"
HREF="node18.html">
<IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next"
SRC="/usr/share/latex2html/icons/next.png"></A>
<A NAME="tex2html331"
HREF="node15.html">
<IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up"
SRC="/usr/share/latex2html/icons/up.png"></A>
<A NAME="tex2html325"
HREF="node16.html">
<IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous"
SRC="/usr/share/latex2html/icons/prev.png"></A>
<A NAME="tex2html333"
HREF="node4.html">
<IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents"
SRC="/usr/share/latex2html/icons/contents.png"></A>
<A NAME="tex2html334"
HREF="node58.html">
<IMG WIDTH="43" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="index"
SRC="/usr/share/latex2html/icons/index.png"></A>
<BR>
<B> Next:</B> <A NAME="tex2html336"
HREF="node18.html">Predefined Phyla and Operators</A>
<B> Up:</B> <A NAME="tex2html332"
HREF="node15.html">Output</A>
<B> Previous:</B> <A NAME="tex2html326"
HREF="node16.html">Generated Data Types</A>
<BR>
<BR>
<!--End of Navigation Panel-->
<H2><A NAME="SECTION00072000000000000000"> </A>
<A NAME="gen-func"> </A>
<BR>
Generated Functions
</H2>
In this section we describe the various functions that are generated.
Every function can be used like any other C function.
In the names, the following `meta' notation is used:
<UL>
<LI>
<EM>phylum</EM> is a phylum name (user-defined or predefined),
in the list functions <EM>phylum</EM> corresponds to the list elements.
<LI>
<EM>list</EM> is the name of a list phylum.
<LI>
<EM>Operator</EM> is an operator name.
<LI>
<EM>result function</EM>(); is the definition of a function found
in the term processor input.
</UL>
<P>
<!-- MATH: $\fbox{\sf {\em phylum} {\em Operator}( {\em phylum\_sub1} sub1, ..., {\em phylum\_subn} subn );}$ -->
<IMG
WIDTH="426" HEIGHT="27" ALIGN="BOTTOM" BORDER="0"
SRC="img4.gif"
ALT="\fbox{\sf {\em phylum} {\em Operator}( {\em phylum\_sub1} sub1, ..., {\em phylum\_subn} subn );}">
<P>
For each operator a C function is declared, with the same name.
This function implements the storage option and returns (a pointer to) the term
constructed from its arguments.
<P>
<!-- MATH: $\fbox{\parbox{7cm}{
void *emalloc( kc\_size\_t n ); \\
void *ecalloc( kc\_size\_t n, kc\_size\_t m ); \\
void *erealloc( void *r, kc\_size\_t s ); \\
}}$ -->
<IMG
WIDTH="328" HEIGHT="80" ALIGN="BOTTOM" BORDER="0"
SRC="img5.gif"
ALT="\fbox{\parbox{7cm}{
void *emalloc( kc\_size\_t n ); \\
void *ecalloc( kc\_size\_t n, kc\_size\_t m ); \\
void *erealloc( void *r, kc\_size\_t s ); \\
}}"><A NAME="1358"> </A><A NAME="1359"> </A><A NAME="1360"> </A>
<P>
The <I>emalloc</I> and friends functions are used for allocating memory, they call the system memory
allocation routines and check the return status.
The <I>emalloc</I> and friends functions' interfaces use the <I>void*</I> type<A NAME="tex2html3"
HREF="footnode.html#foot1361"><SUP>3</SUP></A>, and hide the fact that some <I>malloc</I> libraries use the <I>char*</I> type from the user.
<P>
The <I>uniqmalloc</I> and friends routines are used to implement the hashtables' storage.
They claim large chunks from the system and pass out small blocks.
These blocks cannot be freed by themselves, it is only possible
to free a complete collection of chunks as a whole.
Each collection of chunks can be identified by its <I>kc_memory_info_t*</I>.
<P>
<!-- MATH: $\fbox{\sf kc\_memory\_info\_t *uniqmallocinit( kc\_size\_t n );}$ -->
<IMG
WIDTH="329" HEIGHT="27" ALIGN="BOTTOM" BORDER="0"
SRC="img6.gif"
ALT="\fbox{\sf kc\_memory\_info\_t *uniqmallocinit( kc\_size\_t n );}"><A NAME="1362"> </A>
<P>
Initialize the allocation information of a new set-of-chunks and return a pointer to it.
<P>
<!-- MATH: $\fbox{\sf void *uniqmalloc( kc\_size\_t n, kc\_memory\_info\_t *mi );}$ -->
<IMG
WIDTH="374" HEIGHT="27" ALIGN="BOTTOM" BORDER="0"
SRC="img7.gif"
ALT="\fbox{\sf void *uniqmalloc( kc\_size\_t n, kc\_memory\_info\_t *mi );}"><A NAME="1363"> </A>
<P>
Returns a pointer to a block of size <I>n</I> from the chunks administrated in <I>mi</I>.
<P>
<!-- MATH: $\fbox{\sf boolean isinuniqmalloccedblock( void *p, kc\_memory\_info\_t *mi );}$ -->
<IMG
WIDTH="450" HEIGHT="27" ALIGN="BOTTOM" BORDER="0"
SRC="img8.gif"
ALT="\fbox{\sf boolean isinuniqmalloccedblock( void *p, kc\_memory\_info\_t *mi );}"><A NAME="1364"> </A>
<P>
Report whether or not <I>p</I> was allocated via <I>mi</I>.
<P>
<!-- MATH: $\fbox{\sf void uniqfreeall( kc\_memory\_info\_t *mi ); }$ -->
<IMG
WIDTH="289" HEIGHT="27" ALIGN="BOTTOM" BORDER="0"
SRC="img9.gif"
ALT="\fbox{\sf void uniqfreeall( kc\_memory\_info\_t *mi ); }"><A NAME="1365"> </A>
<P>
Free all chunks allocated (managed) via <I>mi </I>.
<P>
<!-- MATH: $\fbox{\sf void uniqfreeelement( void *, kc\_memory\_info\_t *mi );}$ -->
<IMG
WIDTH="371" HEIGHT="27" ALIGN="BOTTOM" BORDER="0"
SRC="img10.gif"
ALT="\fbox{\sf void uniqfreeelement( void *, kc\_memory\_info\_t *mi );}"><A NAME="1366"> </A>
<P>
Free one block allocated by <I>uniqmalloc</I>. However, its current implementation is a no-op.
<P>
In the generated code these allocation routines are used via the following macros:
<I>MALLOC</I><A NAME="1367"> </A> and friends are used for all
allocation, except for the allocation of memory by the <EM>Operator</EM> functions.
<I>UNIQMALLOC2</I><A NAME="1368"> </A> is used to allocate
memory for the phyla that have the `uniq' storage option.
<I>NONUNIQMALLOC</I><A NAME="1369"> </A> is used for the
remaining phyla.
If you want different ones, redefine <I>MALLOC</I> and friends, in your
included code.
For example, the default definition of <I>MALLOC</I> and <I>NONUNIQMALLOC</I> is <I>emalloc</I>,
the default definition of <I>UNIQMALLOC2</I> is <I>uniqmalloc</I>.
<P>
<I>kc_size_t</I><A NAME="1370"> </A> is by default typedef'ed to <I>unsigned</I>.
<P>
The generated code contains the definition of the enumerated type
<I>kc_storageclass_t</I><A NAME="1371"> </A>
, which contains all storage classes, including
the predefined storage class <I>uniq</I>.
<P>
<!-- MATH: $\fbox{\sf kc\_hashtable\_t kc\_ht\_assign( kc\_hashtable\_t ht, kc\_storageclass\_t sc );}$ -->
<IMG
WIDTH="469" HEIGHT="27" ALIGN="BOTTOM" BORDER="0"
SRC="img11.gif"
ALT="\fbox{\sf kc\_hashtable\_t kc\_ht\_assign( kc\_hashtable\_t ht, kc\_storageclass\_t sc );}"><A NAME="1372"> </A>
<P>
Makes <I>ht</I> the hashtable for storage class <I>sc</I>, and return the previously assigned hashtable.
<P>
<!-- MATH: $\fbox{\sf kc\_hashtable\_t kc\_ht\_assigned( kc\_storageclass\_t sc );}$ -->
<IMG
WIDTH="361" HEIGHT="27" ALIGN="BOTTOM" BORDER="0"
SRC="img12.gif"
ALT="\fbox{\sf kc\_hashtable\_t kc\_ht\_assigned( kc\_storageclass\_t sc );}"><A NAME="1373"> </A>
<P>
Return the hashtable assigned to storage class <I>sc</I>.
<P>
<!-- MATH: $\fbox{\sf kc\_hashtable\_t kc\_ht\_create\_simple( kc\_size\_t n );}$ -->
<IMG
WIDTH="335" HEIGHT="27" ALIGN="BOTTOM" BORDER="0"
SRC="img13.gif"
ALT="\fbox{\sf kc\_hashtable\_t kc\_ht\_create\_simple( kc\_size\_t n );}"><A NAME="1374"> </A>
<P>
Creates a hashtable of size <I>n</I>,
using the <I>kc_ht_create_bucketmanagement</I> routine with default
allocation routines (<I>uniqmalloc</I> and friends).
For the <I>bucket_alloc</I> routines <I>ecalloc</I> and friends are used.
<P>
<!-- MATH: $\fbox{\parbox{10cm}{
kc\_hashtable\_t kc\_ht\_create( \\
\mbox{}\hspace{2cm} kc\_size\_t n, \\
\mbox{}\hspace{2cm} void *(*uniq\_malloc\_init)(), \\
\mbox{}\hspace{2cm} void *(*uniq\_malloc)(kc\_size\_t n, void *mi), \\
\mbox{}\hspace{2cm} void (*uniq\_free\_element)(void *p, void *mi), \\
\mbox{}\hspace{2cm} void (*uniq\_free\_all)(void *p, void *mi), \\
\mbox{}\hspace{2cm} boolean (*in\_block)(void *p, void *mi) );
}}$ -->
<IMG
WIDTH="464" HEIGHT="141" ALIGN="BOTTOM" BORDER="0"
SRC="img14.gif"
ALT="\fbox{\parbox{10cm}{
kc\_hashtable\_t kc\_ht\_create( \\
\mbox{}\hspace{2cm} kc...
...void *mi), \\
\mbox{}\hspace{2cm} boolean (*in\_block)(void *p, void *mi) );
}}">
<A NAME="1376"> </A>
<P>
Creates a hashtable of size <I>n</I> with the given allocation routines.
A <I>0</I> argument can be given for <I>uniq_free_all</I>,
<I>uniq_free_element</I> and/or for <I>in_block</I>, if those routines
are not implemented.
This routine uses the <I>kc_ht_create_bucketmanagement</I> routine with
default bucket allocation routines (<I>ecalloc</I> and friends).
<P>
<!-- MATH: $\fbox{\parbox{13cm}{
kc\_hashtable\_t kc\_ht\_create\_bucketmanagement( \\
\mbox{}\hspace{2cm} kc\_size\_t n, \\
\mbox{}\hspace{2cm} void *(*uniq\_malloc\_init)(), \\
\mbox{}\hspace{2cm} void *(*uniq\_malloc)(kc\_size\_t n, void *mi), \\
\mbox{}\hspace{2cm} void (*uniq\_free\_element)(void *p, void *mi), \\
\mbox{}\hspace{2cm} void (*uniq\_free\_all)(void *p, void *mi), \\
\mbox{}\hspace{2cm} boolean (*in\_block)(void *p, void *mi), \\
\mbox{}\hspace{2cm} void (*uniq\_info)(void *mi), \\
\mbox{}\hspace{2cm} void *(*bucket\_alloc\_init)(), \\
\mbox{}\hspace{2cm} void *(*bucket\_calloc)(kc\_size\_t n, kc\_size\_t s, void *bi), \\
\mbox{}\hspace{2cm} void *(*bucket\_realloc)(void *b, kc\_size\_t old, kc\_size\_t new, void *bi), \\
\mbox{}\hspace{2cm} void (*bucket\_free)(void *b, kc\_size\_t s, void *bi), \\
\mbox{}\hspace{2cm} void (*bucket\_free\_all)(void *bi), \\
\mbox{}\hspace{2cm} int bucket\_increment, \\
\mbox{}\hspace{2cm} void (*bucket\_info)(void *mi) );
}}$ -->
<IMG
WIDTH="600" HEIGHT="294" ALIGN="BOTTOM" BORDER="0"
SRC="img15.gif"
ALT="\fbox{\parbox{13cm}{
kc\_hashtable\_t kc\_ht\_create\_bucketmanagement( \\
\mbo...
... bucket\_increment, \\
\mbox{}\hspace{2cm} void (*bucket\_info)(void *mi) );
}}">
<A NAME="1378"> </A>
<P>
Creates a hashtable of size <I>n</I> with the given allocation routines.
A <I>0</I> argument can be given for <I>uniq_free_all</I>,
<I>uniq_free_element</I> and/or for <I>in_block</I>, if those routines
are not implemented, as well as for the info routines, and either the
<I>bucket_free</I> or the <I>bucket_free_all</I> routines.
<P>
<!-- MATH: $\fbox{\sf void kc\_ht\_clear( kc\_hashtable\_t ht);}$ -->
<IMG
WIDTH="250" HEIGHT="27" ALIGN="BOTTOM" BORDER="0"
SRC="img16.gif"
ALT="\fbox{\sf void kc\_ht\_clear( kc\_hashtable\_t ht);}"><A NAME="1379"> </A>
<P>
Clears hashtable <I>ht</I>, ie. frees its elements
(either using <I>uniq_free_elements</I> or, preferably, <I>uniq_free_all</I>),
and its buckets. The result of this routine should be equivalent with calling
<I>kc_ht_delete</I> followed by <I>kc_ht_create</I>.
<P>
<!-- MATH: $\fbox{\sf void kc\_ht\_delete( kc\_hashtable\_t ht); }$ -->
<IMG
WIDTH="264" HEIGHT="27" ALIGN="BOTTOM" BORDER="0"
SRC="img17.gif"
ALT="\fbox{\sf void kc\_ht\_delete( kc\_hashtable\_t ht); }"><A NAME="1380"> </A>
<P>
First <I>kc_ht_clear</I>s the hashtable, and then frees the hashtable itself.
<P>
<!-- MATH: $\fbox{\sf void kc\_ht\_reuse( kc\_hashtable\_t ht);}$ -->
<IMG
WIDTH="253" HEIGHT="27" ALIGN="BOTTOM" BORDER="0"
SRC="img18.gif"
ALT="\fbox{\sf void kc\_ht\_reuse( kc\_hashtable\_t ht);}"><A NAME="1381"> </A>
<P>
Prepares hashtable <I>ht</I> for reuse, ie. frees its elements, but not its buckets.
<P>
<!-- MATH: $\fbox{\parbox{7cm}{
{\sf casestring mkcasestring( char *s ); \\
nocasestring mknocasestring( char *s );
}}}$ -->
<IMG
WIDTH="328" HEIGHT="46" ALIGN="BOTTOM" BORDER="0"
SRC="img19.gif"
ALT="\fbox{\parbox{7cm}{
{\sf casestring mkcasestring( char *s ); \\
nocasestring mknocasestring( char *s );
}}}"><A NAME="1383"> </A><A NAME="1384"> </A>
<P>
The basic phylum constructors.
They convert a value of a C string into the corresponding phylum value.
From a <I>casestring</I> or <I>nocasestring</I>
value the string can be referenced as <I>cs-</I>><I>name</I>.
In the case of case insensitive strings, this field will contain the string as it is capitalized at its
first occurrence.
<P>
<!-- MATH: $\fbox{\sf {\em result} {\em function}( {\em args} );}$ -->
<IMG
WIDTH="161" HEIGHT="27" ALIGN="BOTTOM" BORDER="0"
SRC="img20.gif"
ALT="\fbox{\sf {\em result} {\em function}( {\em args} );}">
<P>
The template of user-provided functions.
<P>
<!-- MATH: $\fbox{\sf boolean eq\_{\em phylum}( {\em phylum} p1, {\em phylum} p2 );}$ -->
<IMG
WIDTH="315" HEIGHT="27" ALIGN="BOTTOM" BORDER="0"
SRC="img21.gif"
ALT="\fbox{\sf boolean eq\_{\em phylum}( {\em phylum} p1, {\em phylum} p2 );}"><A NAME="1463"> </A>
<P>
The function that tests for structural equality of terms.
Attribute values do not influence the comparison.
If the phylum is uniquely represented, the test always takes constant time.
Note that the comparison of a <I>casestring</I> with a <I>nocasestring</I> is not
type correct.
<P>
<!-- MATH: $\fbox{\sf void free\_{\em phylum}( {\em phylum} p, boolean recursive);}$ -->
<IMG
WIDTH="331" HEIGHT="27" ALIGN="BOTTOM" BORDER="0"
SRC="img22.gif"
ALT="\fbox{\sf void free\_{\em phylum}( {\em phylum} p, boolean recursive);}"><A NAME="1464"> </A>
<P>
The node <I>p</I> is zeroed and freed.
If <I>recursive</I> is <I>True</I>, the subterms are freed as well.
The body of a free function for a phylum with storage class <I>uniq</I> is empty.
<P>
<!-- MATH: $\fbox{\sf void freelist\_{\em list}( {\em list} p );}$ -->
<IMG
WIDTH="173" HEIGHT="27" ALIGN="BOTTOM" BORDER="0"
SRC="img23.gif"
ALT="\fbox{\sf void freelist\_{\em list}( {\em list} p );}"><A NAME="1465"> </A>
<P>
Free the list, but not the elements of the list.
In other words, free the spine.
<P>
<!-- MATH: $\fbox{\sf {\em list} concat\_{\em list}( {\em list} l1, {\em list} l2);}$ -->
<IMG
WIDTH="210" HEIGHT="27" ALIGN="BOTTOM" BORDER="0"
SRC="img24.gif"
ALT="\fbox{\sf {\em list} concat\_{\em list}( {\em list} l1, {\em list} l2);}"><A NAME="1466"> </A>
<P>
Produce a new list that is the concatenation of the two arguments.
If the second argument is the empty list, and the list phylum is not uniquely
represented, this is equivalent to a copy of the list nodes (the `spine').
The list elements are never copied.
<P>
<!-- MATH: $\fbox{\sf {\em phylum} copy\_{\em phylum}( {\em phylum} p, boolean copy\_attributes );}$ -->
<IMG
WIDTH="405" HEIGHT="27" ALIGN="BOTTOM" BORDER="0"
SRC="img25.gif"
ALT="\fbox{\sf {\em phylum} copy\_{\em phylum}( {\em phylum} p, boolean copy\_attributes );}"><A NAME="1467"> </A>
<P>
Return a copy of <I>p</I>.
If <I>copy_attributes</I> is <I>False</I> attribute values are initialised
as defined in the definition of <EM>phylum</EM>.
If <I>copy_attributes</I> is <I>True</I> the values of the attributes are copied.
Please note that this does not imply that the attributes themselves are copied.
This function is ineffective on uniquely represented phyla.
<P>
<!-- MATH: $\fbox{\sf {\em list} reverse\_{\em list}( {\em list} l);}$ -->
<IMG
WIDTH="157" HEIGHT="27" ALIGN="BOTTOM" BORDER="0"
SRC="img26.gif"
ALT="\fbox{\sf {\em list} reverse\_{\em list}( {\em list} l);}"><A NAME="1468"> </A>
<P>
Produce a list that is the reverse of the argument list.
<P>
<!-- MATH: $\fbox{\sf int length\_{\em list}( {\em list} l);}$ -->
<IMG
WIDTH="151" HEIGHT="27" ALIGN="BOTTOM" BORDER="0"
SRC="img27.gif"
ALT="\fbox{\sf int length\_{\em list}( {\em list} l);}"><A NAME="1469"> </A>
<P>
Yield the number of elements in a list, a nil list has zero elements.
<P>
<!-- MATH: $\fbox{\sf {\em phylum} last\_{\em list}( {\em list} l);}$ -->
<IMG
WIDTH="164" HEIGHT="27" ALIGN="BOTTOM" BORDER="0"
SRC="img28.gif"
ALT="\fbox{\sf {\em phylum} last\_{\em list}( {\em list} l);}"><A NAME="1470"> </A>
<P>
Yield the last element of a list, or an error if there isn't one.
<P>
<!-- MATH: $\fbox{\sf {\em list} map\_{\em list}( {\em list} l, {\em phylum}(*f)({\em phylum}));}$ -->
<IMG
WIDTH="286" HEIGHT="27" ALIGN="BOTTOM" BORDER="0"
SRC="img29.gif"
ALT="\fbox{\sf {\em list} map\_{\em list}( {\em list} l, {\em phylum}(*f)({\em phylum}));}"><A NAME="1471"> </A>
<P>
Yield the list constructed from the element-wise application of <I>f</I>.
It `lifts' <I>f</I> to a function on lists.
<P>
<!-- MATH: $\fbox{\sf {\em list} filter\_{\em list}( {\em list} l, boolean(*f)({\em phylum}));}$ -->
<IMG
WIDTH="291" HEIGHT="27" ALIGN="BOTTOM" BORDER="0"
SRC="img30.gif"
ALT="\fbox{\sf {\em list} filter\_{\em list}( {\em list} l, boolean(*f)({\em phylum}));}"><A NAME="1472"> </A>
<P>
Yield the list of elements of which <I>f</I> is <I>True</I>.
<P>
<!-- MATH: $\fbox{\parbox{8cm}{
{\sf void fprint\_{\em phylum}( FILE *f, {\em phylum} p ); \\
void print\_{\em phylum}( {\em phylum} p );
}}}$ -->
<IMG
WIDTH="373" HEIGHT="46" ALIGN="BOTTOM" BORDER="0"
SRC="img31.gif"
ALT="\fbox{\parbox{8cm}{
{\sf void fprint\_{\em phylum}( FILE *f, {\em phylum} p ); \\
void print\_{\em phylum}( {\em phylum} p );
}}}"><A NAME="1474"> </A>
<A NAME="1475"> </A>
<P>
Print the argument term on a given file
(<I>f = 0</I> means standard output -
<I>print_<EM>phylum</EM>( <EM>p</EM> )</I> is identical to
<I>fprint_<EM>phylum</EM>( 0, <EM>p</EM> )</I>) in a canonical format.
In this format each operator appears on a separate line.
It is mainly intended for debugging.
<P>
<!-- MATH: $\fbox{\parbox{10cm}{
void fprintdot\_{\em phylum}( \\
\mbox{}\hspace{2cm} FILE *f, \\
\mbox{}\hspace{2cm} {\em phylum} p, \\
\mbox{}\hspace{2cm} char *root\_label\_prefix, \\
\mbox{}\hspace{2cm} char *edge\_label\_prefix, \\
\mbox{}\hspace{2cm} char *edge\_attributes, \\
\mbox{}\hspace{2cm} boolean print\_node\_labels, \\
\mbox{}\hspace{2cm} boolean use\_context\_when\_sharing\_leaves, \\
\mbox{}\hspace{2cm} boolean print\_prologue\_and\_epilogue ); \\
void fprintdotprologue( FILE *f ); \\
void fprintdotepilogue( FILE *f );
}}$ -->
<IMG
WIDTH="464" HEIGHT="218" ALIGN="BOTTOM" BORDER="0"
SRC="img32.gif"
ALT="\fbox{\parbox{10cm}{
void fprintdot\_{\em phylum}( \\
\mbox{}\hspace{2cm} FILE ...
...\\
void fprintdotprologue( FILE *f ); \\
void fprintdotepilogue( FILE *f );
}}">
<A NAME="1477"> </A>
<A NAME="1413"> </A>
<A NAME="1414"> </A>
<P>
Print the argument term <I>p</I>, with its attributes, on a given file
(<I>f = 0</I> means standard output) in <EM>dot</EM> input format.
<EM>Dot</EM> is a program that draws directed acyclic graphs in various output
formats, among which are postscript and gif.
It is available as part of the <EM>GraphViz</EM> graph visualisation package[<A
HREF="node57.html#graphviz">EKN</A>].
If <I>print_node_labels</I> is <I>True</I>,
the nodes are labeled with the names of the operators, the types of the subtrees,
and the attribute names and types (or values, for boolean attributes),
and the root node is labeled with <I>root_label_prefix</I> followed by <EM>phylum</EM>.
The edges are numbered; the edge numbers show a depth-first left-to-right treewalk.
The numbers are prefixed with the contents of <I>edge_label_prefix</I>,
which can make it easier to see to which tree an edge belongs when
several trees are combined in the same picture, as discussed below.
Attributes of the edges (colors, fonts, etc.) can be given with <I>edge_attributes</I>.
Shared non-leaf tree nodes appear as such in the drawing.
For leaf nodes (like integers, (no)casestrings) the amount of sharing
can be influenced with the
<I>use_context_when_sharing_leaves</I> argument:
if it is <I>False</I> leaf nodes with the same value will be shared
(which resembles the internal program structure, but may give pictures that
are a bit confusing, especially if no non-leaf nodes are shared),
if it is <I>True</I> then the ancestor of the leaf node is taken into account
for the sharing, i.e. leaf nodes with the same value but different ancestors
will not be shared.
Finally, it is possible to combine several trees in one drawing.
To do so, start by invoking <I>fprintdotprologue</I>.
Next, invoke <I>fprintdot_<EM>phylum</EM></I> for each tree, with argument
<I>print_prologue_and_epilogue</I> set to <I>False</I>.
You likely want to use a different <I>edge_label_prefix</I> for each tree.
Finally, invoke <I>fprintdotepilogue</I>.
If only one tree is to be drawn, then it is sufficient to invoke
<I>fprintdot_<EM>phylum</EM></I> with <I>print_prologue_and_epilogue</I>
set to <I>True</I> (and <I>fprintdotprologue</I> and <I>fprintdotepilogue</I>
need not be invoked 'by hand').
<P>
<!-- MATH: $\fbox{\sf int kc\_set\_fprintdot\_hashtablesize( int s );}$ -->
<IMG
WIDTH="286" HEIGHT="27" ALIGN="BOTTOM" BORDER="0"
SRC="img33.gif"
ALT="\fbox{\sf int kc\_set\_fprintdot\_hashtablesize( int s );}"><A NAME="1417"> </A>
<P>
Set the size of the hashtable that the <I>fprintdot_<EM>phylum</EM></I>
routines use to detect node-sharing.
Return the previous value.
<P>
<!-- MATH: $\fbox{\sf {\em phylum} rewrite\_{\em phylum}( {\em phylum} p, rview v );}$ -->
<IMG
WIDTH="311" HEIGHT="27" ALIGN="BOTTOM" BORDER="0"
SRC="img34.gif"
ALT="\fbox{\sf {\em phylum} rewrite\_{\em phylum}( {\em phylum} p, rview v );}"><A NAME="1478"> </A>
<P>
Yield the normal form of the first argument with respect to the rewrite system and view.
<P>
<!-- MATH: $\fbox{\sf void unparse\_{\em phylum}( {\em phylum} p, void(*kc\_printer)(char *s, uview v), uview kc\_current\_view );}$ -->
<IMG
WIDTH="633" HEIGHT="27" ALIGN="BOTTOM" BORDER="0"
SRC="img35.gif"
ALT="\fbox{\sf void unparse\_{\em phylum}( {\em phylum} p, void(*kc\_printer)(char *s, uview v), uview kc\_current\_view );}"><A NAME="1479"> </A>
<P>
Unparses the argument <I>p</I> and its descendants, with view and printer as given.
<P>
<!-- MATH: $\fbox{\parbox{8cm}{
{\sf char *CSGIOread\_{\em phylum}( FILE *f, {\em phylum} *ptr ); \\
char *CSGIOwrite\_{\em phylum}( FILE *f, {\em phylum} p );
}}}$ -->
<IMG
WIDTH="373" HEIGHT="46" ALIGN="BOTTOM" BORDER="0"
SRC="img36.gif"
ALT="\fbox{\parbox{8cm}{
{\sf char *CSGIOread\_{\em phylum}( FILE *f, {\em phylum} *ptr ); \\
char *CSGIOwrite\_{\em phylum}( FILE *f, {\em phylum} p );
}}}"><A NAME="1481"> </A>
<A NAME="1482"> </A>
<P>
To read and write a term from a
structure file (see Section <A HREF="node27.html#sg-io">3.5</A>).
<I>FILE</I> is the standard file i/o type defined in <<I>stdio.h</I>>.
The functions return a null pointer if all went well.
If not, they return a pointer to a string containing an error message.
<P>
<!-- MATH: $\fbox{\sf int kc\_set\_csgio\_hashtablesize( int s );}$ -->
<IMG
WIDTH="261" HEIGHT="27" ALIGN="BOTTOM" BORDER="0"
SRC="img37.gif"
ALT="\fbox{\sf int kc\_set\_csgio\_hashtablesize( int s );}"><A NAME="1426"> </A>
<P>
Set the size of the hashtable that the <I>CSGIOwrite_<EM>phylum</EM></I>
routines use to detect node-sharing.
Return the previous value.
<P>
<!-- MATH: $\fbox{\sf boolean kc\_set\_csgio\_sharing( boolean b );}$ -->
<IMG
WIDTH="291" HEIGHT="27" ALIGN="BOTTOM" BORDER="0"
SRC="img38.gif"
ALT="\fbox{\sf boolean kc\_set\_csgio\_sharing( boolean b );}"><A NAME="1428"> </A>
<P>
Disable (<I>b = False</I>) or re-enable the use of node-sharing while <EM>writing</EM> structure files.
This does not affect the ability to <EM>read</EM> structure files that contain node-sharing!
By default (if this routine is not called) node-sharing in structure files is enabled.
Return the previous value.
<P>
<!-- MATH: $\fbox{\sf void kc\_print\_operator\_statistics( FILE *f );}$ -->
<IMG
WIDTH="297" HEIGHT="27" ALIGN="BOTTOM" BORDER="0"
SRC="img39.gif"
ALT="\fbox{\sf void kc\_print\_operator\_statistics( FILE *f );}"><A NAME="1429"> </A>
<P>
Print for each operator its size in bytes,
the number of create calls, the number
of actually created elements
(usually much lower if its phylum has the <I>uniq</I> storage option),
the number of free calls (recursive and non-recursive), the number of freed elements,
the number of remaining nodes and the amount of space that these take, in bytes.
The routine is equivalent to a no-op, unless the preprocessor symbol
<I>KC_STATISTICS</I><A NAME="1430"> </A> is defined.
<P>
<!-- MATH: $\fbox{\sf void kc\_print\_hash\_statistics( FILE *f );}$ -->
<IMG
WIDTH="271" HEIGHT="27" ALIGN="BOTTOM" BORDER="0"
SRC="img40.gif"
ALT="\fbox{\sf void kc\_print\_hash\_statistics( FILE *f );}"><A NAME="1431"> </A>
<P>
Print the number of hashtable buckets that contain zero, one, two, three,
four, five, six, seven, eight or more elements.
<P>
<!-- MATH: $\fbox{\sf void kc\_print\_hashtable\_memory\_statistics( FILE *f, kc\_hashtable\_t h );}$ -->
<IMG
WIDTH="480" HEIGHT="27" ALIGN="BOTTOM" BORDER="0"
SRC="img41.gif"
ALT="\fbox{\sf void kc\_print\_hashtable\_memory\_statistics( FILE *f, kc\_hashtable\_t h );}"><A NAME="1432"> </A>
<P>
Print information about the memory management of <I>h</I>.
(This will only be possible if node- and bucket memory-management routines
have been specified.)
<P>
<HR>
<!--Navigation Panel-->
<A NAME="tex2html335"
HREF="node18.html">
<IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next"
SRC="/usr/share/latex2html/icons/next.png"></A>
<A NAME="tex2html331"
HREF="node15.html">
<IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up"
SRC="/usr/share/latex2html/icons/up.png"></A>
<A NAME="tex2html325"
HREF="node16.html">
<IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous"
SRC="/usr/share/latex2html/icons/prev.png"></A>
<A NAME="tex2html333"
HREF="node4.html">
<IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents"
SRC="/usr/share/latex2html/icons/contents.png"></A>
<A NAME="tex2html334"
HREF="node58.html">
<IMG WIDTH="43" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="index"
SRC="/usr/share/latex2html/icons/index.png"></A>
<BR>
<B> Next:</B> <A NAME="tex2html336"
HREF="node18.html">Predefined Phyla and Operators</A>
<B> Up:</B> <A NAME="tex2html332"
HREF="node15.html">Output</A>
<B> Previous:</B> <A NAME="tex2html326"
HREF="node16.html">Generated Data Types</A>
<!--End of Navigation Panel-->
<ADDRESS>
<I></I>
<BR><I>2000-04-17</I>
</ADDRESS>
</BODY>
</HTML>
|