You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@rickb777
A PushSlice and InsertSlice are probably not needed, since they seem like an uncommon operation and their purpose, aside from some syntactic convenience, is to avoid possible multiple resizes when adding a number of items. The caller can already do this using the Grow function:
Adding iterator adaptors IterPopFront and IterPopBack, might be unnecessary when the caller can already do:
forq.Len() !=0 {
process(q.PopFront())
}
The iterator looks like:
for item := range IterPopFront() {
process(item)
}
So it does not really simplify the code. However, it may still be worth adding these iterators to eliminate intermediate resizes during iteration. Somewhat like the inverse of Grow. See PR #32.
As for a Full function, it seems like it is syntactic sugar for something that is likely not very common. I think if q.Len() == q.Cap() is a bit more explicit. If a size limit is desired them it might be better wrap Deque in a type that checks if Len is at the limit when adding items. The wrapper's PushBask can then return a bool or error to indicate that the limit has been reached. If it is necessary to block on a write to a full Deque, or a read from an empty Deque, then channelqueue does exactly this. WDYT?
Continued from #28, from @rickb777
Here are some ideas for methods that you could add:
Full() bool
method - a shortcut forq.Len() == q.Cap()
which would be useful for anyone wanting to impose a maximum size or avoid resizingThe text was updated successfully, but these errors were encountered: