• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

ut_std_vector.h

Go to the documentation of this file.
00001 /* -*- mode: C++; tab-width: 4; c-basic-offset: 4; -*- */
00002 /* AbiSource Program Utilities
00003  * Copyright (C) 2011 Hubert Figuiere
00004  *
00005  * This program is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU General Public License
00007  * as published by the Free Software Foundation; either version 2
00008  * of the License, or (at your option) any later version.
00009  *
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program; if not, write to the Free Software
00017  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00018  * 02110-1301 USA.
00019  */
00020 
00021 
00022 
00023 #ifndef __UT_STD_VECTOR_H__
00024 #define __UT_STD_VECTOR_H__
00025 
00026 #include "ut_assert.h"
00027 
00028 // TODO I'm sure we can template the sparse out of it.
00029 template <class V>
00030 void UT_std_vector_sparsepurgeall(V & v)
00031 {
00032     for(typename V::iterator iter = v.begin();iter != v.end(); ++iter) {
00033         if(*iter) {
00034             delete *iter;
00035         }
00036     }
00037 }
00038 
00039 template <class V>
00040 void UT_std_vector_purgeall(V & v)
00041 {
00042     for(typename V::iterator iter = v.begin();iter != v.end(); ++iter) {
00043         UT_ASSERT_HARMLESS(*iter);
00044         if(*iter) {
00045             delete *iter;
00046         }
00047     }
00048 }
00049 
00050 template <class V, typename F>
00051 void UT_std_vector_freeall(V & v, F free_func = g_free)
00052 {
00053     for(typename V::iterator iter = v.begin();iter != v.end(); ++iter) {
00054         if(*iter) {
00055             free_func(*iter);
00056         }
00057     }
00058 }
00059 
00060 #endif

Generated on Sun Feb 14 2021 for AbiWord by  doxygen 1.7.1