Doubly Linked-List, Linked-lists and dynamic arrays in C++ -
i'm new c++ , these questions simple , basic [and sorry that!]. here have 2 basic questions:
as understand vectors in c++ dynamic arrays. can change size pushing back/front elements them.
my question is: vectors allocated dynamically or "dynamic array" name called because of changing size capability? dynamically allocated array , dynamic arrays make me confused!
- stl lists linked-lists in c++ (again, understand). these doubly-linked lists or singly-linked list?
thanks,
vectors allocated dynamically, can see in mentioned documentation. can see better in push_back
function:
if new size() greater capacity() iterators , references (including past-the-end iterator) invalidated. otherwise past-the-end iterator invalidated.
also, stick in mind complexity amortized constant (as instance, can see this).
for more info (mentioned in comments), can find real list forward_list
:
it implemented singly-linked list , not have overhead compared implementation in c. compared std::list container provides more space efficient storage when bidirectional iteration not needed.
also, mentioned in documentation, list implemented doubly linked list.
list containers implemented doubly-linked lists; doubly linked lists can store each of elements contain in different , unrelated storage locations. ordering kept internally association each element of link element preceding , link element following it.
Comments
Post a Comment