mirror of
git://sourceware.org/git/newlib-cygwin.git
synced 2025-02-02 12:30:24 +08:00
34124a0718
2_12-branch'. Sprout from gdb_5_1-2001-07-29-branch 2001-07-26 14:20:06 UTC cvs2svn 'This commit was manufactured by cvs2svn to create branch' Cherrypick from master 2002-02-09 22:54:16 UTC Richard Henderson <rth@redhat.com> ' * alpha.h (R_ALPHA_BRSGP): New.': COPYING.NEWLIB ChangeLog MAINTAINERS Makefile.in config.guess config.sub configure configure.in etc/ChangeLog etc/Makefile.in gettext.m4 include/ChangeLog include/ansidecl.h include/aout/ChangeLog include/aout/aout64.h include/aout/hp300hpux.h include/bfdlink.h include/coff/ChangeLog include/coff/arm.h include/coff/external.h include/coff/internal.h include/coff/m88k.h include/coff/or32.h include/coff/ti.h include/coff/tic54x.h include/coff/xcoff.h include/demangle.h include/dis-asm.h include/dyn-string.h include/elf/ChangeLog include/elf/alpha.h include/elf/arm.h include/elf/common.h include/elf/dwarf2.h include/elf/external.h include/elf/h8.h include/elf/ia64.h include/elf/internal.h include/elf/mips.h include/elf/mmix.h include/elf/or32.h include/elf/ppc.h include/elf/sh.h include/elf/xstormy16.h include/fibheap.h include/filenames.h include/floatformat.h include/hashtab.h include/libiberty.h include/nlm/ChangeLog include/nlm/common.h include/objalloc.h include/opcode/ChangeLog include/opcode/alpha.h include/opcode/arc.h include/opcode/avr.h include/opcode/cgen.h include/opcode/d10v.h include/opcode/d30v.h include/opcode/h8300.h include/opcode/hppa.h include/opcode/i386.h include/opcode/mips.h include/opcode/mmix.h include/opcode/or32.h include/opcode/ppc.h include/opcode/tic54x.h include/opcode/v850.h include/partition.h include/safe-ctype.h include/sort.h include/splay-tree.h include/xregex.h libtool.m4 ltcf-c.sh ltcf-cxx.sh ltcf-gcj.sh ltconfig ltmain.sh symlink-tree
82 lines
2.8 KiB
C
82 lines
2.8 KiB
C
/* List implementation of a partition of consecutive integers.
|
|
Copyright (C) 2000, 2001 Free Software Foundation, Inc.
|
|
Contributed by CodeSourcery, LLC.
|
|
|
|
This file is part of GCC.
|
|
|
|
GCC is free software; you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation; either version 2, or (at your option)
|
|
any later version.
|
|
|
|
GCC is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with GCC; see the file COPYING. If not, write to
|
|
the Free Software Foundation, 59 Temple Place - Suite 330,
|
|
Boston, MA 02111-1307, USA. */
|
|
|
|
/* This package implements a partition of consecutive integers. The
|
|
elements are partitioned into classes. Each class is represented
|
|
by one of its elements, the canonical element, which is chosen
|
|
arbitrarily from elements in the class. The principal operations
|
|
on a partition are FIND, which takes an element, determines its
|
|
class, and returns the canonical element for that class, and UNION,
|
|
which unites the two classes that contain two given elements into a
|
|
single class.
|
|
|
|
The list implementation used here provides constant-time finds. By
|
|
storing the size of each class with the class's canonical element,
|
|
it is able to perform unions over all the classes in the partition
|
|
in O (N log N) time. */
|
|
|
|
#ifndef _PARTITION_H
|
|
#define _PARTITION_H
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif /* __cplusplus */
|
|
|
|
#include <ansidecl.h>
|
|
#include <stdio.h>
|
|
|
|
struct partition_elem
|
|
{
|
|
/* The canonical element that represents the class containing this
|
|
element. */
|
|
int class_element;
|
|
/* The next element in this class. Elements in each class form a
|
|
circular list. */
|
|
struct partition_elem* next;
|
|
/* The number of elements in this class. Valid only if this is the
|
|
canonical element for its class. */
|
|
unsigned class_count;
|
|
};
|
|
|
|
typedef struct partition_def
|
|
{
|
|
/* The number of elements in this partition. */
|
|
int num_elements;
|
|
/* The elements in the partition. */
|
|
struct partition_elem elements[1];
|
|
} *partition;
|
|
|
|
extern partition partition_new PARAMS((int));
|
|
extern void partition_delete PARAMS((partition));
|
|
extern int partition_union PARAMS((partition,
|
|
int,
|
|
int));
|
|
extern void partition_print PARAMS((partition,
|
|
FILE*));
|
|
|
|
/* Returns the canonical element corresponding to the class containing
|
|
ELEMENT__ in PARTITION__. */
|
|
|
|
#define partition_find(partition__, element__) \
|
|
((partition__)->elements[(element__)].class_element)
|
|
|
|
#endif /* _PARTITION_H */
|