Your skill will accomplish what the force of many cannot |
|
PerlMonks |
Re^7: [OT:] Is this Curriculum right?by eyepopslikeamosquito (Archbishop) |
on Nov 27, 2021 at 08:01 UTC ( [id://11139166]=note: print w/replies, xml ) | Need Help?? |
... just use the Perl array and use splice to insert or delete if you need to ... there is no need for a specific linked list implementation in Perl Agreed. I too find Perl's arrays a delight to use. :)
I guess that I don't really understand what is meant by a C++ vector A C++ vector is similar to a Perl array. Like C arrays, C++ vectors use contiguous storage locations for their elements (great for CPU cache performance), while their size can change dynamically, with storage handled automatically by the container (great for protection from dreaded C memory faults).
A Perl hash table calculates a "vector" to a short linked list. Perl has an algorithm such that, in general, when these "short linked lists" become too long, Perl doubles the hash size and creates more "vectors". I have not studied how Perl implements its hash tables; I hope to find more time to study them in the future. The standard C++ library equivalent of a Perl hash are the UnorderedAssociativeContainers, especially std::map and std::unordered_map. Though the C++ standard library is an interface and does not specify implementation (thus allowing library implementations to adapt to new hardware in the future), I believe that std::map is usually implemented using red-black trees, while std::unordered_map (closest to Perl's hashes) is usually implemented, apparently due to a small "oversight" in the specification, by "storing a linked list to external nodes in the array of buckets". There are a wide variety of associative containers in the C++ standard library, all sharing a similar interface. For example, in High Performance Game of Life:
In Section
Seekers of Perl Wisdom
|
|