diff options
author | Davi Arnaut <Davi.Arnaut@Sun.COM> | 2010-06-10 22:30:49 -0300 |
---|---|---|
committer | Davi Arnaut <Davi.Arnaut@Sun.COM> | 2010-06-10 22:30:49 -0300 |
commit | db2fe44c844e969405095220287ea98a57f33284 (patch) | |
tree | 7aee99151209c7e83d2cf2ec0b242e6827f8c55f /sql/sql_list.h | |
parent | 90343dd788471cbc384f7f11b7d48fc474ece4c5 (diff) | |
parent | 0f9ddfa9d8bb8d071266bcc63e92813cf18ccd2b (diff) | |
download | mariadb-git-db2fe44c844e969405095220287ea98a57f33284.tar.gz |
Merge of mysql-5.1-bugteam into mysql-trunk-merge.
Diffstat (limited to 'sql/sql_list.h')
-rw-r--r-- | sql/sql_list.h | 56 |
1 files changed, 36 insertions, 20 deletions
diff --git a/sql/sql_list.h b/sql/sql_list.h index 60d9697a606..d57534b0999 100644 --- a/sql/sql_list.h +++ b/sql/sql_list.h @@ -67,45 +67,61 @@ public: /** - Struct to handle simple linked lists. - - @todo What is the relation between this class and list_node, below? - /Matz - - @see list_node, base_list, List + Simple intrusive linked list. + @remark Similar in nature to base_list, but intrusive. It keeps a + a pointer to the first element in the list and a indirect + reference to the last element. */ -typedef struct st_sql_list { +template <typename T> +class SQL_I_List :public Sql_alloc +{ +public: uint elements; - uchar *first; - uchar **next; + /** The first element in the list. */ + T *first; + /** A reference to the next element in the list. */ + T **next; + + SQL_I_List() { empty(); } + + SQL_I_List(const SQL_I_List &tmp) + { + elements= tmp.elements; + first= tmp.first; + next= elements ? tmp.next : &first; + } - st_sql_list() {} /* Remove gcc warning */ inline void empty() { - elements=0; - first=0; + elements= 0; + first= NULL; next= &first; } - inline void link_in_list(uchar *element,uchar **next_ptr) + + inline void link_in_list(T *element, T **next_ptr) { elements++; - (*next)=element; + (*next)= element; next= next_ptr; - *next=0; + *next= NULL; } - inline void save_and_clear(struct st_sql_list *save) + + inline void save_and_clear(SQL_I_List<T> *save) { *save= *this; empty(); } - inline void push_front(struct st_sql_list *save) + + inline void push_front(SQL_I_List<T> *save) { - *save->next= first; /* link current list last */ + /* link current list last */ + *save->next= first; first= save->first; elements+= save->elements; } - inline void push_back(struct st_sql_list *save) + + inline void push_back(SQL_I_List<T> *save) { if (save->first) { @@ -114,7 +130,7 @@ typedef struct st_sql_list { elements+= save->elements; } } -} SQL_LIST; +}; /* |