gl_anylinked_list1.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /* Sequential list data type implemented by a linked list.
  2. Copyright (C) 2006, 2009-2013 Free Software Foundation, Inc.
  3. Written by Bruno Haible <bruno@clisp.org>, 2006.
  4. This program is free software: you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 3 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program. If not, see <http://www.gnu.org/licenses/>. */
  14. /* Common code of gl_linked_list.c and gl_linkedhash_list.c. */
  15. /* -------------------------- gl_list_t Data Type -------------------------- */
  16. /* Concrete list node implementation, valid for this file only. */
  17. struct gl_list_node_impl
  18. {
  19. #if WITH_HASHTABLE
  20. struct gl_hash_entry h; /* hash table entry fields; must be first */
  21. #endif
  22. struct gl_list_node_impl *next;
  23. struct gl_list_node_impl *prev;
  24. const void *value;
  25. };
  26. /* Concrete gl_list_impl type, valid for this file only. */
  27. struct gl_list_impl
  28. {
  29. struct gl_list_impl_base base;
  30. #if WITH_HASHTABLE
  31. /* A hash table: managed as an array of collision lists. */
  32. struct gl_hash_entry **table;
  33. size_t table_size;
  34. #endif
  35. /* A circular list anchored at root.
  36. The first node is = root.next, the last node is = root.prev.
  37. The root's value is unused. */
  38. struct gl_list_node_impl root;
  39. /* Number of list nodes, excluding the root. */
  40. size_t count;
  41. };