queue

Help trying to understand modulo operation in circular array

China☆狼群 提交于 2019-12-23 18:32:46
问题 i have a small issue trying to figure out how a modulo operation is being calculated. I am building up a queue, so i have a circular array. i cannot figure out how this modulo operation works. Given q: an array of Character of 5 elements length, The MAX constant gives the max length of the array "5" rare is an int which represents the first available spot in the array q public void enqueue(Character c)throws FullQueueException{ if(size()== MAX -1){ //if only 1 place left, is full, throw exc

AudioQueueStart reporting unsupported format

心已入冬 提交于 2019-12-23 16:43:00
问题 I'm trying to get audio queue working on an iphone app, and whenever AudioQueueStart is called it gives the "fmt?" result code (kAudioFormatUnsupportedDataFormatError). In the code below i'm setting the format to kAudioFormatLinearPCM, which surely is supported. What am i doing wrong? data.mDataFormat.mSampleRate = 44100; data.mDataFormat.mFormatID = kAudioFormatLinearPCM; data.mDataFormat.mFormatFlags = 0; data.mDataFormat.mBytesPerPacket = 4; data.mDataFormat.mFramesPerPacket = 1; data

Simple Pull Message Queue

江枫思渺然 提交于 2019-12-23 15:28:42
问题 I'm trying to find the right tool for the job. I've explored a few different message queues like Kafka, Kestrel, etc... and I'm looking for something that has a PULL functionality. I have an API (distributed) that shoves the incoming messages into the queue. I'd then have workers (separate machines) that pull messages from the queue. This ensures that the workers don't get flooded and can't handle the load of the queue. I'm wondering if Kafka or Kestrel supports this type of functionality 回答1

Pygame event queue

…衆ロ難τιáo~ 提交于 2019-12-23 14:53:04
问题 I would like to know if there is a way of using poll() or get() without removing the events from the queue. In my game, I check input at different places (not only in the main loop) and sometimes I need to check the same event at different places but when i check it once it removes it from the queue. I tried using peek() but the problem is that I can't get the key corresponding to the event done. while 1: event = pygame.event.poll() if event.type == KEYDOWN: return event.key else: pass #works

How do I set up a mock queue using mockrunner to test an xml filter?

橙三吉。 提交于 2019-12-23 12:17:24
问题 I'm using the mockrunner package from http://mockrunner.sourceforge.net/ to set up a mock queue for JUnit testing an XML filter which operates like this: sets recognized properties for an ftp server to put and get xml input and a jms queue server that keeps track of jobs. Remotely there waits a server that actually parses the xml once a queue message is received. creates a remote directory using ftp and starts a queue connection using mqconnectionfactory to the given address of the queue

Find if an item already exists in STL queue

无人久伴 提交于 2019-12-23 12:07:56
问题 I am using an STL queue to implement a BFS (breadth first search) on a graph. I need to push a node in the queue if that node already doesn't exist in the queue. However, STL queue does not allow iteration through its elements and hence I cannot use the STL find function. I could use a flag for each node to mark them when they are visited and push them only when the flag is false, however, I need to run BFS multiple times and after each time I will have to reset all the flags, so I ended up

How does queue.js work?

折月煮酒 提交于 2019-12-23 10:49:08
问题 I've been trying to understand how Mike Bostock's queue.js works, but I can't see how it manages to work. The part I don't understand is how the code manages to continue executing callbacks. In particular, I am unsure about the pop() method (line 45). From my understanding, the method takes the next unprocessed, deferred function; appends a callback that (potentially) starts the next deferred function in the queue and executes when the immediately popped function finishes; then finally

Removing from STL std::queue without destructing the removed object?

喜欢而已 提交于 2019-12-23 08:28:44
问题 All the documentation I can find on the STL containers (both queue and list) say that for any of the remove functions the removed object's destructor is called. This means that I can't use std::queue any time I want a queue that's simply a list of objects needing some operation performed on them. I want to be able to add objects to the queue when they are waiting in line for me to do something to them. Then I want to remove them from it when I've finished with them, without destroying the

Does C++ have standard queue?

纵然是瞬间 提交于 2019-12-23 08:06:27
问题 I know that there's a standard library vector in C++. Is there a queue? An online search suggests there might be, but there's not much about it if there is one. Edit: All right. Thanks a ton guys. 回答1: std::queue (container adaptor) 回答2: Yes there is, you could choose the underlying container easily also if you are interested: #include <queue> int main() { std::queue<int> myqueue; myqueue.push(3); int x = myqueue.front(); myqueue.pop(); // pop is void! } 回答3: Yes, there's std::queue .

Is there a Queue (PriorityQueue) implementation which is also a Set?

核能气质少年 提交于 2019-12-23 07:40:06
问题 I'm looking for a PriorityQueue implementation which is also a Set. The compareTo implementation if its elements must not have the requirement to be consistent with the implementation of equals . Is there somewhere such a implementation for java? Update: I implemented it now using a SortedSet as the internal collection. So I only had to implement the missing methods to satisfy the queue interface. I also forgot to mention that it also had to be a bounded queue, so it features a capacity and