Difference between revisions of "cpp/named req/SequenceContainer"
From cppreference.com
m (r2.7.3) (Robot: Adding de, es, fr, it, ja, pt, ru, zh) |
|||
Line 109: | Line 109: | ||
{{dcl list item|std::deque|Efficient insertion/deletion at the beginning and at the end of the sequence}} | {{dcl list item|std::deque|Efficient insertion/deletion at the beginning and at the end of the sequence}} | ||
{{dcl list end}} | {{dcl list end}} | ||
+ | |||
+ | [[de:cpp/concept/SequenceContainer]] | ||
+ | [[es:cpp/concept/SequenceContainer]] | ||
+ | [[fr:cpp/concept/SequenceContainer]] | ||
+ | [[it:cpp/concept/SequenceContainer]] | ||
+ | [[ja:cpp/concept/SequenceContainer]] | ||
+ | [[pt:cpp/concept/SequenceContainer]] | ||
+ | [[ru:cpp/concept/SequenceContainer]] | ||
+ | [[zh:cpp/concept/SequenceContainer]] |
Revision as of 13:51, 2 November 2012
Template:cpp/concept/title Template:cpp/concept/navbar
A SequenceContainer
is a Template:concept that stores objects of the same type in a linear arrangement.
Contents |
Requirements
Legend | |
X
|
Container type |
T
|
Element type |
a , b
|
Objects of type X
|
t
|
Object of type T
|
n
|
Positive integer |
i , j
|
Template:concepts denoting a valid range |
il
|
std::initializer_list<T> |
args
|
Parameter pack |
p , q
|
const_iterators in a
|
expression | return type | effects | precondition | postcondition |
---|---|---|---|---|
X(n,t) | Constructs a SequenceContainer containing n copies of t |
T Template:concept | std::distance(begin(),end()) == n | |
X(i,j) | Constructs a SequenceContainer equivalent to the range [i,j)
|
|
std::distance(begin(),end()) == std::distance(i,j) | |
X(il) | X(il.begin(),il.end) | |||
a = il | X& | Assigns the range represented by il into a
|
T Template:concept and Template:concept | Existing elements of a are destroyed or assigned to
|
a.emplace(p,args) | iterator | Insert an object constructed with std::forward<Args>(args) before p
|
|
|
a.emplace(p,t) | iterator | Inserts a copy of t before i
|
|
|
a.insert(p,n,t) | iterator | Inserts n copies of t before i
|
T Template:concept and Template:concept | |
a.insert(p,i,j) | iterator | Inserts copies of elements in [i, j) before p
|
|
Each iterator in [i,j) is dereferenced once
|
a.insert(p, il) | iterator | a.insert(p,il.begin(),il.end()) | ||
a.erase(q) | iterator | Erases the element pointed to by q | (std::deque, std::vector) T Template:concept | |
a.erase(p,q) | iterator | Erases elements in [p,q) |
(std::deque, std::vector) T Template:concept | |
a.clear() | void | Destroys all elements in a |
| |
a.assign(i,j) | void | Replaces elements in a with a copy of [i, j)
|
|
Each iterator in [i,j) is dereferenced once
|
a.assign(il) | void | a.assign(il.begin(),il.end()) | ||
a.assign(n,t) | void | Replaces elements in a with n copies of t
|
T Template:concept and Template:concept |
Optional Operations
This section is incomplete |
SequenceContainers in the standard library
Trade-offs / usage notes
std::array | Fast access but fixed number of elements |
std::vector | Fast access but mostly inefficient insertions/deletions |
std::list std::forward_list |
Efficient insertion/deletion in the middle of the sequence |
std::deque | Efficient insertion/deletion at the beginning and at the end of the sequence |