From a07e0280b245200f483e170d446156f1dea261f3 Mon Sep 17 00:00:00 2001 From: Gabriel Corona Date: Tue, 12 Jul 2016 15:05:15 +0200 Subject: [PATCH 1/1] [doc] Suggest C++ alternatives to xbt containers --- doc/doxygen/module-xbt.doc | 2 ++ include/xbt/dict.h | 3 ++- include/xbt/dynar.h | 2 ++ include/xbt/fifo.h | 8 ++++++-- include/xbt/heap.h | 2 ++ include/xbt/swag.h | 1 + 6 files changed, 15 insertions(+), 3 deletions(-) diff --git a/doc/doxygen/module-xbt.doc b/doc/doxygen/module-xbt.doc index ee62c0a120..ef58360d1a 100644 --- a/doc/doxygen/module-xbt.doc +++ b/doc/doxygen/module-xbt.doc @@ -64,6 +64,8 @@ Here are the basic data containers that every C programmer rewrites one day. You won't need to do so yourself, you lucky one, because we did it for you. + However, if you are programming in C++ you might want to use C++ containers + instead. @{ */ /** @defgroup XBT_dynar Dynar: generic dynamic array */ diff --git a/include/xbt/dict.h b/include/xbt/dict.h index 87c70ec12f..b3cfd35ef3 100644 --- a/include/xbt/dict.h +++ b/include/xbt/dict.h @@ -21,6 +21,8 @@ SG_BEGIN_DECL() * This section describes the API to a dictionary structure that associates as string to a void* key. It provides the * same functionality than an hash table. * + * If you are using C++, you might want to use `std::unordered_map` instead. + * * Here is a little example of use: \verbatim @@ -33,7 +35,6 @@ SG_BEGIN_DECL() sprintf(buff,"another good stuff"); xbt_dict_set(mydict,"my data", strdup(buff), free); // previous data gets erased (and freed) by second add \endverbatim - * */ /** @defgroup XBT_dict_cons Dict constructor and destructor diff --git a/include/xbt/dynar.h b/include/xbt/dynar.h index b8cfbdd336..874eb46f5b 100644 --- a/include/xbt/dynar.h +++ b/include/xbt/dynar.h @@ -25,6 +25,8 @@ SG_BEGIN_DECL() * \ref XBT_dict section). You thus have to provide the function which will be used to free the content at * structure creation (of type void_f_ppvoid_t or void_f_pvoid_t). * + * If you are using C++, you might want to use `std::vector` instead. + * * \section XBT_dynar_exscal Example with scalar * \dontinclude dynar.cpp * diff --git a/include/xbt/fifo.h b/include/xbt/fifo.h index c373926d1f..5f6432b458 100644 --- a/include/xbt/fifo.h +++ b/include/xbt/fifo.h @@ -14,9 +14,13 @@ SG_BEGIN_DECL() /** @addtogroup XBT_fifo * @brief This section describes the API to generic workqueue. * - * These functions provide the same kind of functionality as dynamic arrays but in time O(1). - * However these functions use malloc/free way too much often. + * These functions provide the same kind of functionality as dynamic arrays + * but in time O(1). However these functions use malloc/free way too much often. + * + * If you are using C++, you might want to used std::list, std::deque or + * std::queue instead. */ + /** @defgroup XBT_fifo_cons Fifo constructor and destructor * @ingroup XBT_fifo * diff --git a/include/xbt/heap.h b/include/xbt/heap.h index ddf76dd8b4..3fe2951540 100644 --- a/include/xbt/heap.h +++ b/include/xbt/heap.h @@ -15,6 +15,8 @@ SG_BEGIN_DECL() /** @addtogroup XBT_heap * @brief This section describes the API to generic heap with O(log(n)) access. * + * If you are using C++ you might want to use std::priority_queue instead. + * * @{ */ /* @brief heap datatype */ diff --git a/include/xbt/swag.h b/include/xbt/swag.h index ecbdb15c46..318be64069 100644 --- a/include/xbt/swag.h +++ b/include/xbt/swag.h @@ -24,6 +24,7 @@ SG_BEGIN_DECL() * It is basically a fifo but with restrictions so that it can be used as a set. Any operation (add, remove, belongs) * is O(1) and no call to malloc/free is done. * + * If you are using C++, you might want to use boost::intrusive::set instead. */ /** @defgroup XBT_swag_type Swag types @ingroup XBT_swag -- 2.20.1