int main (int argc, char* argv[]) { int val1 = 1; int val2 = 2; int val3 = 3; int val4 = 4; Queue q = QueueNew(); QueuePut(q, &val1, INT_VALUE); QueuePut(q, &val2, INT_VALUE); QueuePut(q, &val3, INT_VALUE); QueuePut(q, &val4, INT_VALUE); QueueItem qptr = q->head; while (qptr != NULL) { int* val = (int*) qptr->element; printf("value: %d\n", *val); qptr = qptr->next; } QueueIterator qiter = QueueIteratorNew(q, 1); while (qiter->currentItem != NULL) { int* val = (int*) qiter->currentItem->element; printf("iterator value: %d\n", *val); QueueIteratorAdvance(qiter); } }
/* Give the level-order travel number to each node */ void BFS1() { NODE *pNode; LISTNODE *pList; QueuePut(root); while ( ! QueueEmpty() ) { pNode = QueueGet(); pNode->nodeno = node_count++; for ( pList = pNode->childList; pList; pList = pList->next ) { QueuePut( pList->pNode ); } } }
LW_RTOS_RESULT lw_QueuePut (tQueueHandle QueueId, void * pItemBuffer, tTicks Timeout) { if (QueuePut ( (tQueueHeader *)QueueId, pItemBuffer)) return LWR_OK; else return LWR_ERROR; }
/** * Modification of I/O scheme: * This tree is generated after libchewing * construction, so the size of tree must be * obtained from size of file returned by * plat_mmap_create() and sizeof(PHLTreeType). */ void BFS2(const char* bin_name) { NODE *pNode; LISTNODE *pList; PHLTreeType tree={0}; FILE* output; #ifdef USE_BINARY_DATA output=fopen(PHL_KEY_TREE_FILE, "wb"); #else output=fopen(PHL_KEY_TREE_FILE, "w"); #endif if(!output){ fprintf(stderr, "%s: Cannot open " PHL_KEY_TREE_FILE " for output.\n", bin_name); exit(1); } QueuePut(root); tree_size=0; while(!QueueEmpty()){ pNode = QueueGet(); tree.keyin_id=pNode->key; tree.phrase_id=pNode->phraseno; /* compute the begin and end index */ pList=pNode->childList; if(pList){ tree.child_begin = pList->pNode->nodeno; for(; pList->next; pList=pList->next) QueuePut(pList->pNode); QueuePut( pList->pNode ); tree.child_end = pList->pNode->nodeno; } else tree.child_begin=tree.child_end=-1; #ifdef USE_BINARY_DATA fwrite(&tree, sizeof(PHLTreeType), 1, output); #else fprintf(output, "%lu %d %d %d\n", tree.keyin_id, tree.phrase_id, tree.child_begin, tree.child_end); #endif tree_size++; } fclose(output); }
static void OnRadioRxDone( uint8_t *payload, uint16_t size, int16_t rssi, int8_t snr ) { LoRaPhy_PacketDesc packet; LOG_DEBUG("Received %u bytes.", size); packet.flags = LORAPHY_PACKET_FLAGS_NONE; packet.phyData = payload; packet.rxtx = LORAPHY_BUF_PAYLOAD_START(packet.phyData); packet.phySize = LORAPHY_BUFFER_SIZE; if ( QueuePut(packet.phyData, packet.phySize, size, true, false, true, packet.flags) == ERR_OK ) { phyFlags.Bits.RxDone = 1; } else { LOG_ERROR("Failed to put received frame to queue."); } }
uint8_t LoRaPhy_QueueRxMessage( uint8_t *payload, size_t payloadSize, bool toBack, uint8_t flags ) { return QueuePut(payload, LORAPHY_BUFFER_SIZE, payloadSize, false, false, toBack, flags); }
uint8_t LoRaPhy_PutPayload( uint8_t *buf, size_t bufSize, size_t payloadSize, uint8_t flags ) { return QueuePut(buf, bufSize, payloadSize, false, true, true, flags); }