Linux内核常用数据结构

链表

/////////////////////操作链表////////////////////////////////

/*增加节点*/list_add(struct list_head *new, struct list_head *head);//在head节点后插入new节点list_add_tail(struct list_head *new, struct list_head *head);//在head节点前插入new节点

/*删除节点*/list_del(struct list_head *entry);//将节点entry从链表中删除list_del_init(struct list_head *entry);//将节点entry从链表中删除,并初始化entry节点

/*移动节点*/list_move(struct list_head *list, struct list_head *head);//移除list项并加入head节点后面list_move_tail(struct list_head *new, struct list_head *head);//移除list项并加入head节点前面

/*链表判空*/list_empty(struct list_head *head);//链表为空,返回非0;否则返回0

list_entry(ptr,type, member);//获取member的父类型结构体

/*合并节点*/list_splice(struct list_head *list, struct list_head *head);//把两个未连接的链表合并在一起:把list指向的链表插入到指定链表的head后面list_splice_init(struct list_head *list, struct list_head *head);//把两个未连接的链表合并在一起,并重新初始化原来的链表

list_splice_tail(struct list_head *list, struct list_head *head);//把两个未连接的链表合并在一起:把list指向的链表插入到指定链表的head前面list_splice_tail_init(struct list_head *list, struct list_head *head);//把两个未连接的链表合并在一起,并重新初始化原来的链表

//////////////////////遍历链表/////////////////////////////////list_for_each_entry(pos, head, member);//沿着next指针向前遍历

list_for_each_entry_reverse(pos, head, member);//沿着prev指针向后遍历

list_for_each_entry_safe(pos, next, head, member);//沿着next指针向前遍历,且可删除pos

list_for_each_entry_safe_reverse(pos, next, head, member);//沿着next指针向前遍历,且可删除pos

哈希链表

红黑树

风景如何,其实并不重要。重要的是,你在我的身边。

Linux内核常用数据结构

相关文章:

你感兴趣的文章:

标签云: