Two queue header files C Language

Source: Internet
Author: User

/* Binomial-queue.h -- two queue header files */<br/>/* It is a good idea to load header files in the header file */<br/> # include <stdio. h> <br/> # include <stdlib. h> <br/> # define infinity 32767 <br/>/* data type definition */</P> <p> typedef int item; // Why do I like int ^ <br/> typedef struct node <br/>{< br/> item; <br/> struct node * left; // left subtree <br/> struct node * nextsibling; // left sibling <br/>} node; <br/> typedef node * subtree; <br/> typedef struct binqueue <br/>{< br/> subtree * forest; <br/> int size; <br/> int current; <br/>} * binqueue; </P> <p>/* interface function declaration */</P> <p>/* operation: before initializing a two-item queue */<br/>/* operation: PBq points to a two-item queue, and size indicates its size */<br/>/* operation: if the memory allocation is successful, 1 is returned if the two queues of this size are empty during initialization; otherwise, 0 */<br/> int initializebinqueue (binqueue * const PBq, const int size); </P> <p>/* operation: determines whether a two-item queue is empty */<br/>/* before the operation: BQ is an initialized two-item queue */<br/>/*: If the queue is empty, 1 is returned; otherwise, 0 */<br/> int binqueueisempty (const binqueue Bq) is returned. </P> <p>/* operation: merge two queues */<br/>/* Before operation: bq1, bq2 is two initialized two queues */<br/>/* after operation: if the merged two-item queue can be placed in bq1 and bq1 and bq2 are not the same two-item queue, the new merged queue is returned; otherwise, the original bq1 */<br/> binqueue Merge (binqueue bq1, binqueue bq2) is returned. </P> <p>/* operation: before inserting an element into a two-item queue */<br/>/*: BQ is an initialized two-item queue, item is a new element */<br/>/*: if the two queues are not full, add the item to the queue and return the new queue; otherwise, the system returns the original queue */<br/> binqueue insert (binqueue Bq, const item); </P> <p>/* operation: delete and return the minimum element of a Two-item queue */<br/>/* before the operation: PBq points to an initialized two-item queue */<br/>/*: If the queue is not empty, delete the queue and return the minimum element; otherwise, return-infinity */<br/> item deletemin (binqueue Bq); </P> <p>/* operation: before a function is sequentially applied to all elements in the Two-item queue */<br/>/*: BQ is an initialized two-item queue, and pfun points to one with no return value, after receiving the function */<br/>/* for an item parameter: the function pointed to by pfun is applied to all elements in the queue once */<br/> void traversal (const binqueue Bq, void (* pfun) (const item )); </P> <p>/* operation: Release the memory space occupied by a two-item queue */<br/>/* before the operation: BQ is an initialized two-item queue */<br/>/* after the operation: the memory occupied by this queue is cleared */<br/> void release (const binqueue Bq); <br/>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.