Use of the red and black trees in the Linux kernel-general Linux technology-Linux programming and kernel information. The following is a detailed description. Recently, we need to use the red/black tree. When we look for information on the Internet, we accidentally find that there is a red/black tree implementation in the Linux kernel, and its code is very independent. Now we extract it. I have extracted the kernel from 2.6.24 and divided it into two files: rbtree. h and rbtree. c, rbtree. h is located in the include/linux directory of the kernel source code, rbtree. c is located in the lib directory of the kernel source code.
Delete the # include and # include rows in rbtree. h, and add the # include
For the rb_node declaration, delete the last _ attribute _ (aligned (sizeof (long ))))
Add the following macro definitions in rbtree. h: