OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [gdb-5.0/] [include/] [partition.h] - Diff between revs 106 and 107

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 106 Rev 107
/* List implentation of a partition of consecutive integers.
/* List implentation of a partition of consecutive integers.
   Copyright (C) 2000 Free Software Foundation, Inc.
   Copyright (C) 2000 Free Software Foundation, Inc.
   Contributed by CodeSourcery, LLC.
   Contributed by CodeSourcery, LLC.
 
 
   This file is part of GNU CC.
   This file is part of GNU CC.
 
 
   GNU CC is free software; you can redistribute it and/or modify
   GNU CC is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2, or (at your option)
   the Free Software Foundation; either version 2, or (at your option)
   any later version.
   any later version.
 
 
   GNU CC is distributed in the hope that it will be useful,
   GNU CC is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.
   GNU General Public License for more details.
 
 
   You should have received a copy of the GNU General Public License
   You should have received a copy of the GNU General Public License
   along with GNU CC; see the file COPYING.  If not, write to
   along with GNU CC; see the file COPYING.  If not, write to
   the Free Software Foundation, 59 Temple Place - Suite 330,
   the Free Software Foundation, 59 Temple Place - Suite 330,
   Boston, MA 02111-1307, USA.  */
   Boston, MA 02111-1307, USA.  */
 
 
/* This package implements a partition of consecutive integers.  The
/* This package implements a partition of consecutive integers.  The
   elements are partitioned into classes.  Each class is represented
   elements are partitioned into classes.  Each class is represented
   by one of its elements, the canonical element, which is chosen
   by one of its elements, the canonical element, which is chosen
   arbitrarily from elements in the class.  The principal operations
   arbitrarily from elements in the class.  The principal operations
   on a partition are FIND, which takes an element, determines its
   on a partition are FIND, which takes an element, determines its
   class, and returns the canonical element for that class, and UNION,
   class, and returns the canonical element for that class, and UNION,
   which unites the two classes that contain two given elements into a
   which unites the two classes that contain two given elements into a
   single class.
   single class.
 
 
   The list implementation used here provides constant-time finds.  By
   The list implementation used here provides constant-time finds.  By
   storing the size of each class with the class's canonical element,
   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
   it is able to perform unions over all the classes in the partition
   in O (N log N) time.  */
   in O (N log N) time.  */
 
 
#ifndef _PARTITION_H
#ifndef _PARTITION_H
#define _PARTITION_H
#define _PARTITION_H
 
 
#ifdef __cplusplus
#ifdef __cplusplus
extern "C" {
extern "C" {
#endif /* __cplusplus */
#endif /* __cplusplus */
 
 
#include <ansidecl.h>
#include <ansidecl.h>
#include <stdio.h>
#include <stdio.h>
 
 
struct partition_elem
struct partition_elem
{
{
  /* The canonical element that represents the class containing this
  /* The canonical element that represents the class containing this
     element.  */
     element.  */
  int class_element;
  int class_element;
  /* The next element in this class.  Elements in each class form a
  /* The next element in this class.  Elements in each class form a
     circular list.  */
     circular list.  */
  struct partition_elem* next;
  struct partition_elem* next;
  /* The number of elements in this class.  Valid only if this is the
  /* The number of elements in this class.  Valid only if this is the
     canonical element for its class.  */
     canonical element for its class.  */
  unsigned class_count;
  unsigned class_count;
};
};
 
 
typedef struct partition_def
typedef struct partition_def
{
{
  /* The number of elements in this partition.  */
  /* The number of elements in this partition.  */
  int num_elements;
  int num_elements;
  /* The elements in the partition.  */
  /* The elements in the partition.  */
  struct partition_elem elements[1];
  struct partition_elem elements[1];
} *partition;
} *partition;
 
 
extern partition partition_new          PARAMS((int));
extern partition partition_new          PARAMS((int));
extern void partition_delete            PARAMS((partition));
extern void partition_delete            PARAMS((partition));
extern int partition_union              PARAMS((partition,
extern int partition_union              PARAMS((partition,
                                                int,
                                                int,
                                                int));
                                                int));
extern void partition_print             PARAMS((partition,
extern void partition_print             PARAMS((partition,
                                                FILE*));
                                                FILE*));
 
 
/* Returns the canonical element corresponding to the class containing
/* Returns the canonical element corresponding to the class containing
   ELEMENT__ in PARTITION__.  */
   ELEMENT__ in PARTITION__.  */
 
 
#define partition_find(partition__, element__) \
#define partition_find(partition__, element__) \
    ((partition__)->elements[(element__)].class_element)
    ((partition__)->elements[(element__)].class_element)
 
 
#endif /* _PARTITION_H */
#endif /* _PARTITION_H */
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.