Biomechanical Joint Model
 Author: Anderson Maciel

PairData.H

Go to the documentation of this file.
00001 /************************************************************************\
00002 
00003   Copyright 1997 The University of North Carolina at Chapel Hill.
00004   All Rights Reserved.
00005 
00006   Permission to use, copy, modify and distribute this software
00007   and its documentation for educational, research and non-profit
00008   purposes, without fee, and without a written agreement is
00009   hereby granted, provided that the above copyright notice and
00010   the following three paragraphs appear in all copies.
00011 
00012   IN NO EVENT SHALL THE UNIVERSITY OF NORTH CAROLINA AT CHAPEL
00013   HILL BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL,
00014   INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS,
00015   ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION,
00016   EVEN IF THE UNIVERSITY OF NORTH CAROLINA HAVE BEEN ADVISED OF
00017   THE POSSIBILITY OF SUCH DAMAGES.
00018 
00019 
00020   Permission to use, copy, modify and distribute this software
00021   and its documentation for educational, research and non-profit
00022   purposes, without fee, and without a written agreement is
00023   hereby granted, provided that the above copyright notice and
00024   the following three paragraphs appear in all copies.
00025 
00026   THE UNIVERSITY OF NORTH CAROLINA SPECIFICALLY DISCLAIM ANY
00027   WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00028   WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00029   PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS"
00030   BASIS, AND THE UNIVERSITY OF NORTH CAROLINA HAS NO OBLIGATION
00031   TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR
00032   MODIFICATIONS.
00033 
00034 
00035    --------------------------------- 
00036   |Please send all BUG REPORTS to:  |
00037   |                                 |
00038   |   geom@cs.unc.edu               |
00039   |                                 |
00040    ---------------------------------
00041   
00042      
00043   The authors may be contacted via:
00044 
00045   US Mail:  A. Pattekar/J. Cohen/T. Hudson/S. Gottschalk/M. Lin/D. Manocha
00046             Department of Computer Science
00047             Sitterson Hall, CB #3175
00048             University of N. Carolina
00049             Chapel Hill, NC 27599-3175
00050             
00051   Phone:    (919)962-1749
00052             
00053   EMail:    geom@cs.unc.edu
00054 
00055 \************************************************************************/
00056 
00057 
00058 /************************************************************************\
00059 Filename: PairData.H
00060 --
00061 Description: This file declares two classes - Elem and
00062              PairData. Elem is a simple class used by
00063              PairData. PairData stores a set of pairs 
00064              of integers.
00065 
00066 \************************************************************************/
00067 
00068 
00069 #ifndef PAIRDATA_H
00070 #define PAIRDATA_H
00071 
00072 class Elem
00073 {
00074 public:
00075   int   id;
00076   Elem  *next;
00077 };
00078 
00079 
00080 
00081 
00082 /************************************************************************
00083 Class: PairData
00084 --
00085 Description: Each instance of this class stores a set of pairs of
00086              integers. It is assumed that the data is sparse
00087              (i.e. the size of this set is small as compared to
00088              the n*(n-1)/2 possible pairs).
00089 
00090              It should be noted that none of the member functions
00091              of PairData return any error status. For eg., it we
00092              try deleting a pair which doesn't exist, the Delete
00093              operation will simply return.
00094 
00095 \************************************************************************/
00096 
00097 class PairData
00098 {
00099 
00100 private:
00101   inline void OrderIds(int& id1, int& id2);
00102   
00103 public:
00104   int    size;   //the size of array pointed to by "arr"
00105   Elem   **arr;  //arr points to a dynamic array. Each element of
00106                  //this array points to a linked list of
00107                  //"Elem"s.
00108                  //pair (id1, id2) exists <==> max(id1, id2)
00109                  //exists in the linked list pointed to by
00110                  //arr[min(id1, id2)].
00111   
00112   PairData();
00113   ~PairData();
00114   
00115   void   AddPair(int id1, int id2);     //add a pair of ids to the set.
00116   void   DelPair(int id1, int id2);     //delete a pair from the set.
00117   void   DelPairsInvolvingId(int id);   //delete all pairs containing id.
00118   void   Clear(void);                   //empty the set.
00119   int    ExistsPair(int id1, int id2);  //check if a pair of ids exists
00120                                         //in the given set.
00121   
00122 };
00123 
00124 inline void PairData::OrderIds(int &id1, int& id2) //ensures that
00125 {                                                  //id1 = min(id1,id2) and
00126   if (id1 > id2)                                   //id2 = max(id1, id2)
00127     {
00128       int temp = id1;
00129       id1 = id2;
00130       id2 = temp;
00131     }
00132 }
00133 
00134 
00135 #endif /* PAIRDATA_H */

Generated on Thu Dec 1 10:13:39 2005 for COME - Biomechanical Joint Model by  doxygen 1.4.5