4.17. Implementing a Circular List4.17.3. Procedureunshift(@circular, pop(@circular)); # the last shall be first push(@circular, shift(@circular)); # and vice versa 4.17.4. DiscussionCircular lists are commonly used to repeatedly process things in order; for example, connections to a server. The code shown previously isn't a true computer science circular list, with pointers and true circularity. Instead, the operations provide for moving the last element to the first position, and vice versa.
4.17.5. See AlsoThe unshift and push functions in perlfunc(1) and Chapter 29 of Programming Perl; Recipe 13.13
Copyright © 2003 O'Reilly & Associates. All rights reserved. |
|