utlist.h
Go to the documentation of this file.
00001 /*
00002 Copyright (c) 2007-2010, Troy D. Hanson   http://uthash.sourceforge.net
00003 All rights reserved.
00004 
00005 Redistribution and use in source and binary forms, with or without
00006 modification, are permitted provided that the following conditions are met:
00007 
00008     * Redistributions of source code must retain the above copyright
00009       notice, this list of conditions and the following disclaimer.
00010 
00011 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
00012 IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
00013 TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
00014 PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
00015 OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00016 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00017 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00018 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00019 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00020 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00021 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00022 */
00023 
00024 #ifndef UTLIST_H
00025 #define UTLIST_H
00026 
00027 #define UTLIST_VERSION 1.9.1
00028 
00029 /******************************************************************************
00030  * doubly linked list macros (non-circular)                                   *
00031  *****************************************************************************/
00032 #define DL_PREPEND(head,add)                                                                   \
00033 do {                                                                                           \
00034  (add)->next = head;                                                                           \
00035  if (head) {                                                                                   \
00036    (add)->prev = (head)->prev;                                                                 \
00037    (head)->prev = (add);                                                                       \
00038  } else {                                                                                      \
00039    (add)->prev = (add);                                                                        \
00040  }                                                                                             \
00041  (head) = (add);                                                                               \
00042 } while (0)
00043 
00044 #define DL_APPEND(head,add)                                                                    \
00045 do {                                                                                           \
00046   if (head) {                                                                                  \
00047       (add)->prev = (head)->prev;                                                              \
00048       (head)->prev->next = (add);                                                              \
00049       (head)->prev = (add);                                                                    \
00050       (add)->next = NULL;                                                                      \
00051   } else {                                                                                     \
00052       (head)=(add);                                                                            \
00053       (head)->prev = (head);                                                                   \
00054       (head)->next = NULL;                                                                     \
00055   }                                                                                            \
00056 } while (0);
00057 
00058 #define DL_DELETE(head,del)                                                                    \
00059 do {                                                                                           \
00060   if ((del)->prev == (del)) {                                                                  \
00061       (head)=NULL;                                                                             \
00062   } else if ((del)==(head)) {                                                                  \
00063       (del)->next->prev = (del)->prev;                                                         \
00064       (head) = (del)->next;                                                                    \
00065   } else {                                                                                     \
00066       (del)->prev->next = (del)->next;                                                         \
00067       if ((del)->next) {                                                                       \
00068           (del)->next->prev = (del)->prev;                                                     \
00069       } else {                                                                                 \
00070           (head)->prev = (del)->prev;                                                          \
00071       }                                                                                        \
00072   }                                                                                            \
00073 } while (0);
00074 
00075 
00076 #define DL_FOREACH(head,el)                                                                    \
00077     for(el=head;el;el=el->next)
00078 
00079 /* this version is safe for deleting the elements during iteration */
00080 #define DL_FOREACH_SAFE(head,el,tmp)                                                           \
00081   for((el)=(head);(el) && (tmp = (el)->next, 1); (el) = tmp)
00082 
00083 /* these are identical to their singly-linked list counterparts */
00084 #define DL_SEARCH_SCALAR LL_SEARCH_SCALAR
00085 #define DL_SEARCH LL_SEARCH
00086 
00087 #endif
00088 


librealsense
Author(s): Sergey Dorodnicov , Mark Horn , Reagan Lopez
autogenerated on Tue Jun 25 2019 19:54:39