MCPcopy Create free account
hub / github.com/hashintel/hash / enqueue

Method enqueue

libs/@local/hashql/core/src/collections/work_queue.rs:112–119  ·  view source on GitHub ↗

Attempts to enqueue an item if it's not already in the queue. Returns `true` if the `item` was successfully added, or `false` if the item is already present in the queue. # Examples ``` use hashql_core::collections::WorkQueue; # hashql_core::id::newtype!(pub struct MyId(u32 is 0..=100)); let mut queue = WorkQueue::new(100); assert!(queue.enqueue(MyId::new(1))); // Added assert!(!queue.enqueue

(&mut self, item: I)

Source from the content-addressed store, hash-verified

110 /// assert!(queue.enqueue(MyId::new(1))); // Can be added again
111 /// ```
112 pub fn enqueue(&mut self, item: I) -> bool {
113 if self.set.insert(item) {
114 self.queue.push_back(item);
115 true
116 } else {
117 false
118 }
119 }
120
121 /// Removes and returns the next item from the queue.
122 ///

Callers 5

ensureListenerFunction · 0.45
extendMethod · 0.45
startFunction · 0.45
transformFunction · 0.45

Calls 2

push_backMethod · 0.80
insertMethod · 0.45

Tested by

no test coverage detected