summaryrefslogtreecommitdiff
path: root/sql/sql_list.h
diff options
context:
space:
mode:
Diffstat (limited to 'sql/sql_list.h')
-rw-r--r--sql/sql_list.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/sql/sql_list.h b/sql/sql_list.h
index adedd9a3a4d..e71fdc83177 100644
--- a/sql/sql_list.h
+++ b/sql/sql_list.h
@@ -257,6 +257,26 @@ public:
last= &first;
return tmp->info;
}
+
+ /**
+ Cut the list with leaving not more then n elements
+ */
+ inline uint cut(uint n)
+ {
+ list_node *element= first;
+ uint i= 0;
+ for (;
+ i < n && element != &end_of_list;
+ element= element->next, i++);
+ if (element != &end_of_list)
+ {
+ elements= i + 1;
+ last= &element->next;
+ element->next= &end_of_list;
+ }
+ return i + 1;
+ }
+
/*
Remove from this list elements that are contained in the passed list.
We assume that the passed list is a tail of this list (that is, the whole