trie_node.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. * Copyright 2011 Google Inc.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #ifndef DOMAIN_REGISTRY_PRIVATE_TRIE_NODE_H_
  17. #define DOMAIN_REGISTRY_PRIVATE_TRIE_NODE_H_
  18. #pragma pack(push)
  19. #pragma pack(1)
  20. /*
  21. * TrieNode represents a single node in a Trie. It uses 6 bytes of
  22. * storage.
  23. */
  24. struct TrieNode {
  25. /*
  26. * Index in the string table for the hostname-part associated with
  27. * this node.
  28. */
  29. unsigned int string_table_offset : 21;
  30. /*
  31. * Offset of the first child of this node in the node table. All
  32. * children are stored adjacent to each other, sorted
  33. * lexicographically by their hostname parts.
  34. */
  35. unsigned int first_child_offset : 14;
  36. /*
  37. * Number of children of this node.
  38. */
  39. unsigned int num_children : 12;
  40. /*
  41. * Whether this node is a "terminal" node. A terminal node is one
  42. * that represents the end of a sequence of nodes in the trie. For
  43. * instance if the sequences "com.foo.bar" and "com.foo" are added
  44. * to the trie, "bar" and "foo" are terminal nodes, since they are
  45. * both at the end of their sequences.
  46. */
  47. unsigned int is_terminal : 1;
  48. };
  49. #pragma pack(pop)
  50. #endif /* DOMAIN_REGISTRY_PRIVATE_TRIE_NODE_H_ */