source: trunk/src/opengl/glu/tess/priorityq.h

Last change on this file was 2689, checked in by jeroen, 26 years ago

* empty log message *

File size: 4.6 KB
Line 
1/* $Id: priorityq.h,v 1.1 2000-02-09 08:47:36 jeroen Exp $ */
2/*
3** License Applicability. Except to the extent portions of this file are
4** made subject to an alternative license as permitted in the SGI Free
5** Software License B, Version 1.0 (the "License"), the contents of this
6** file are subject only to the provisions of the License. You may not use
7** this file except in compliance with the License. You may obtain a copy
8** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
9** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
10**
11** http://oss.sgi.com/projects/FreeB
12**
13** Note that, as provided in the License, the Software is distributed on an
14** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
15** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
16** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
17** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
18**
19** Original Code. The Original Code is: OpenGL Sample Implementation,
20** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
21** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
22** Copyright in any portions created by third parties is as indicated
23** elsewhere herein. All Rights Reserved.
24**
25** Additional Notice Provisions: The application programming interfaces
26** established by SGI in conjunction with the Original Code are The
27** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
28** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
29** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
30** Window System(R) (Version 1.3), released October 19, 1998. This software
31** was created using the OpenGL(R) version 1.2.1 Sample Implementation
32** published by SGI, but has not been independently verified as being
33** compliant with the OpenGL(R) version 1.2.1 Specification.
34**
35*/
36/*
37** Author: Eric Veach, July 1994.
38**
39** $Date: 2000-02-09 08:47:36 $ $Revision: 1.1 $
40** $Header: /home/ktk/tmp/odin/2007/netlabs.cvs/odin32/src/opengl/glu/tess/priorityq.h,v 1.1 2000-02-09 08:47:36 jeroen Exp $
41*/
42
43#ifndef __priorityq_sort_h_
44#define __priorityq_sort_h_
45
46#include "priorityq-heap.h"
47
48#undef PQkey
49#undef PQhandle
50#undef PriorityQ
51#undef pqNewPriorityQ
52#undef pqDeletePriorityQ
53#undef pqInit
54#undef pqInsert
55#undef pqMinimum
56#undef pqExtractMin
57#undef pqDelete
58#undef pqIsEmpty
59
60/* Use #define's so that another heap implementation can use this one */
61
62#define PQkey PQSortKey
63#define PQhandle PQSortHandle
64#define PriorityQ PriorityQSort
65
66#define pqNewPriorityQ(leq) __gl_pqSortNewPriorityQ(leq)
67#define pqDeletePriorityQ(pq) __gl_pqSortDeletePriorityQ(pq)
68
69/* The basic operations are insertion of a new key (pqInsert),
70 * and examination/extraction of a key whose value is minimum
71 * (pqMinimum/pqExtractMin). Deletion is also allowed (pqDelete);
72 * for this purpose pqInsert returns a "handle" which is supplied
73 * as the argument.
74 *
75 * An initial heap may be created efficiently by calling pqInsert
76 * repeatedly, then calling pqInit. In any case pqInit must be called
77 * before any operations other than pqInsert are used.
78 *
79 * If the heap is empty, pqMinimum/pqExtractMin will return a NULL key.
80 * This may also be tested with pqIsEmpty.
81 */
82#define pqInit(pq) __gl_pqSortInit(pq)
83#define pqInsert(pq,key) __gl_pqSortInsert(pq,key)
84#define pqMinimum(pq) __gl_pqSortMinimum(pq)
85#define pqExtractMin(pq) __gl_pqSortExtractMin(pq)
86#define pqDelete(pq,handle) __gl_pqSortDelete(pq,handle)
87#define pqIsEmpty(pq) __gl_pqSortIsEmpty(pq)
88
89
90/* Since we support deletion the data structure is a little more
91 * complicated than an ordinary heap. "nodes" is the heap itself;
92 * active nodes are stored in the range 1..pq->size. When the
93 * heap exceeds its allocated size (pq->max), its size doubles.
94 * The children of node i are nodes 2i and 2i+1.
95 *
96 * Each node stores an index into an array "handles". Each handle
97 * stores a key, plus a pointer back to the node which currently
98 * represents that key (ie. nodes[handles[i].node].handle == i).
99 */
100
101typedef PQHeapKey PQkey;
102typedef PQHeapHandle PQhandle;
103typedef struct PriorityQ PriorityQ;
104
105struct PriorityQ {
106 PriorityQHeap *heap;
107 PQkey *keys;
108 PQkey **order;
109 PQhandle size, max;
110 int initialized;
111 int (*leq)(PQkey key1, PQkey key2);
112};
113
114PriorityQ *pqNewPriorityQ( int (*leq)(PQkey key1, PQkey key2) );
115void pqDeletePriorityQ( PriorityQ *pq );
116
117int pqInit( PriorityQ *pq );
118PQhandle pqInsert( PriorityQ *pq, PQkey key );
119PQkey pqExtractMin( PriorityQ *pq );
120void pqDelete( PriorityQ *pq, PQhandle handle );
121
122PQkey pqMinimum( PriorityQ *pq );
123int pqIsEmpty( PriorityQ *pq );
124
125#endif
Note: See TracBrowser for help on using the repository browser.