Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Copy/Contents of Methods #13

@stephen304

Description

@stephen304

I'd like to use lane to store a variable list of things where the oldest items are only the ones being removed and the newest go in front. Naturally, a queue from this package would work great, but when printing the contents of the queue, you have to destroy it by popping everything off. This makes my brain hurt when trying to figure out whether I can safely print the contents this way while another thread may be writing to the queue, as the locks are per operation (pop), and there's no way to lock the list for the duration of the copy process.

I would like to propose one of two things:

  • A copy method that would generate a new dequeue, stack, etc struct that is completely independent from the source object - this would allow me to store things in my dequeue and copy it before using dequeue repeatedly to print out the contents
  • A contents (or something) method that would return something like an array of the items in the list. This way I could extract the contents of my dequeue to display without modifying the dequeue.

What do you think?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions