I’m looking for an INotifyCollectionChanged implementation of Stack and Queue. I could roll my own but I don’t want to reinvent the wheel.
I’m looking for an INotifyCollectionChanged implementation of Stack and Queue . I could roll
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
With Stacks and Queues (almost by definition) you only have access to the top of the stack or head of the queue. It’s what differentiates them from a
List. (and so, that’s why you haven’t found one)To answer though you could write your own, I would do it by deriving from
ObservableCollection, then in the case of a stack implementing thePushas anInsertat offset 0 (and pop as returning index 0 thenRemoveAtindex 0); or with a queue you could justAddto the end of the list toEnqueue, and the grab and remove the first item, as with the stack, forDequeue. TheInsert,AddandRemoveAtoperations would be called on the underlyingObservableCollectionand so cause theCollectionChangedevent to be fired.You might also be saying that you simply want to bind or be notified when the one item you are supposed to have access to changes. You would create your own class again, derived from Stack or Queue, and fire the CollectionChanged event manually when: