last update 20 Sep 2009 |
00001 /* 00002 * Copyright (C) 1998 - 2004 00003 * Lehrstuhl fuer Technische Informatik, RWTH-Aachen, Germany 00004 * 00005 * 00006 * This file is part of the Computer Vision and Robotics Library (CVR-Lib) 00007 * 00008 * The CVR-Lib is free software; you can redistribute it and/or 00009 * modify it under the terms of the BSD License. 00010 * 00011 * All rights reserved. 00012 * 00013 * Redistribution and use in source and binary forms, with or without 00014 * modification, are permitted provided that the following conditions are met: 00015 * 00016 * 1. Redistributions of source code must retain the above copyright notice, 00017 * this list of conditions and the following disclaimer. 00018 * 00019 * 2. Redistributions in binary form must reproduce the above copyright notice, 00020 * this list of conditions and the following disclaimer in the documentation 00021 * and/or other materials provided with the distribution. 00022 * 00023 * 3. Neither the name of the authors nor the names of its contributors may be 00024 * used to endorse or promote products derived from this software without 00025 * specific prior written permission. 00026 * 00027 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00028 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00029 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00030 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 00031 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 00032 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 00033 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00034 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 00035 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 00036 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00037 * POSSIBILITY OF SUCH DAMAGE. 00038 */ 00039 00040 00041 /** 00042 * \file cvrList.h 00043 * Defines a wrapper that automatically decides if it is more 00044 * efficient to use the cvr::smallObjectList or the std::list 00045 * \author Gustavo Quiros 00046 * \date 02.04.2004 00047 * 00048 * $Id: cvrList.h,v 1.4 2005/05/24 14:51:56 doerfler Exp $ 00049 */ 00050 00051 #ifndef _CVR_LIST_H_ 00052 #define _CVR_LIST_H_ 00053 00054 #include "cvrObject.h" 00055 #include "cvrIoObject.h" 00056 #include "cvrSmallObjectList.h" 00057 #include <list> 00058 #include "cvrPerformanceConfig.h" 00059 00060 namespace cvr { 00061 00062 template <typename T, bool, class Alloc> 00063 class listHelper : public std::list<T,Alloc> {}; 00064 00065 template <typename T> 00066 class listHelper<T,true,std::allocator<T> > : public smallObjectList<T> {}; 00067 00068 00069 /** 00070 * A linked list, implemented either as a cvr::smallObjectList for 00071 * objects whose size is less than or equal to 00072 * _CVR_PERFORMANCE_LIST_OBJECT_SIZE_THRESHOLD, or as a std::list 00073 * for bigger objects. 00074 * 00075 * In case a different allocator \a Alloc than std::allocator is 00076 * chosen the std::list is used, no matter how big \a T is. This is 00077 * necessary since cvr::smallObjectList doesn't know any allocators. 00078 * 00079 * It is highly recommended that you use cvr::list in all places 00080 * that require a list. Test show superior performance in almost any 00081 * case. If you don't follow this recommendation use 00082 * cvr::smallObjectList or std::list directly and clearly document 00083 * why you have done so 00084 * 00085 * Note that this requires a C++ compiler that supports partial 00086 * template specialization. 00087 */ 00088 template <typename T, class Alloc=std::allocator<T> > 00089 class list 00090 : public listHelper<T,(sizeof(T) <= _CVR_PERFORMANCE_LIST_OBJECT_SIZE_THRESHOLD),Alloc>{ 00091 }; 00092 00093 } 00094 00095 #endif