00001 /* 00002 00003 Copyright (C) 2000, 2001 Silicon Graphics, Inc. All Rights Reserved. 00004 00005 This program is free software; you can redistribute it and/or modify it 00006 under the terms of version 2 of the GNU General Public License as 00007 published by the Free Software Foundation. 00008 00009 This program is distributed in the hope that it would be useful, but 00010 WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00012 00013 Further, this software is distributed without any warranty that it is 00014 free of the rightful claim of any third person regarding infringement 00015 or the like. Any license provided herein, whether implied or 00016 otherwise, applies only to this software file. Patent licenses, if 00017 any, provided herein do not apply to combinations of this program with 00018 other software, or any other product whatsoever. 00019 00020 You should have received a copy of the GNU General Public License along 00021 with this program; if not, write the Free Software Foundation, Inc., 59 00022 Temple Place - Suite 330, Boston MA 02111-1307, USA. 00023 00024 Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pky, 00025 Mountain View, CA 94043, or: 00026 00027 http://www.sgi.com 00028 00029 For further information regarding this notice, see: 00030 00031 http://oss.sgi.com/projects/GenInfo/NoticeExplan 00032 00033 */ 00034 00035 // LRANGE_VSET implementation 00037 00038 // $Revision: 1.2 $ 00039 // $Date: 02/11/07 23:41:30-00:00 $ 00040 // $Author: fchow@keyresearch.com $ 00041 // $Source: /scratch/mee/2.4-65/kpro64-pending/be/cg/gra_mon/SCCS/s.gra_lrange_vset.cxx $ 00042 00043 #ifdef USE_PCH 00044 #include "cg_pch.h" 00045 #endif // USE_PCH 00046 #pragma hdrstop 00047 00048 #ifdef _KEEP_RCS_ID 00049 static char *rcs_id = "$Source: /scratch/mee/2.4-65/kpro64-pending/be/cg/gra_mon/SCCS/s.gra_lrange_vset.cxx $ $Revision: 1.2 $"; 00050 #endif 00051 00052 #include "defs.h" 00053 #ifndef __GNUC__ 00054 #include "bstring.h" 00055 #else 00056 #include "string.h" 00057 #endif 00058 #include "gra_bb.h" 00059 #include "gra_lrange.h" 00060 #include "gra_lrange_vset.h" 00061 00063 // Create and return a new LRANGE_VSET (in the GRA_pool). Its 00064 // elements are given in <vec>, a vector containing <count> 00065 // distinct LRANGE pointers. 00066 LRANGE_VSET* 00067 LRANGE_VSET_Create( LRANGE** vec, size_t count, MEM_POOL *pool ) 00068 { 00069 LRANGE_VSET* result = 00070 (LRANGE_VSET*) MEM_POOL_Alloc(pool, sizeof(LRANGE_VSET) 00071 + (count - 1) * sizeof(LRANGE*)); 00072 // To use bcopy or not? I think that on banyon (due to improved shared 00073 // library version), it will probably do better with long vectors than 00074 // anything we can write in simple C without really understanding which 00075 // compiler will be used. *Sigh* 00076 bcopy((void*) vec, 00077 (void*) (result->vec), 00078 count * sizeof(LRANGE*)); 00079 result->count = count; 00080 return result; 00081 } 00082 00084 // Deletes <lrange> from <vec>. Raises an error if it doesn't 00085 // find <lrange> in <vec>. 00086 void 00087 LRANGE_VSET::Delete_Element( LRANGE* lrange ) 00088 { 00089 size_t i; 00090 00091 for ( i = 0; i < count; ++i ) { 00092 if ( vec[i] == lrange ) { 00093 if ( i < count - 1 ) 00094 vec[i] = vec[count - 1]; 00095 --count; 00096 return; 00097 } 00098 } 00099 00100 DevWarn("LRANGE_VSET::Delete_Element -- LRANGE not found"); 00101 } 00102 00104 // <new> takes the place of <old> 00105 void 00106 LRANGE_VSET::Replace_Element( LRANGE* old_lr, LRANGE* new_lr ) 00107 { 00108 size_t i; 00109 00110 for ( i = 0; i < count; ++i ) { 00111 if ( vec[i] == old_lr ) { 00112 vec[i] = new_lr; 00113 return; 00114 } 00115 } 00116 00117 DevWarn("LRANGE_VSET_Replace_Element -- old LRANGE not found"); 00118 }
1.5.6