.
Object [] toarray ()
Copy the queue element to the new array.
Void trimtosize ()
Set the capacity to the actual number of elements in the queue.
6. Queue usage example
Code
Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--> Class Program{ Static Void Main ( String [] ARGs){ // Create a queue Queue myq = New Queue ();
[Stack first-in-first-out] [Queue first-out]
A linear table is the most basic, simple, and commonly used data structure. The relationship between data elements in a linear table is one-to-one, that is, except the first and last data elements, other data elements are connected at the beginning and end. The logical structure of a linear table is simple for implementation and operation. Therefore, the linear table data structure is widely used in practical applications.
Stack first-in-first-o
. Collections;
Using System. Collections. Generic;
Using System. Linq;
Using System. Text;
Using System. Threading. Tasks;
Namespace queue
{
Class Program
{
Static void Main (string [] args)
{
// Create a queue
Queue myQ = new Queue ();
MyQ. Enqueue ("The"); // enter The queue
MyQ. Enqueue ("quick ");
MyQ. Enqueue ("b
To ensure the thread security of the queue, all operations must be performed through this package.
Enumeration through a set is essentially not a thread-safe process. Other threads can modify the set even when synchronizing the set, which causes an exception in the number of enumerations. To ensure thread security during enumeration, you can lock the set during the enumeration process or catch exceptions caused by changes made by other threads.
The following example shows how to synchronize the
queried data is a single record.In the preceding settings, you must override the GetType (URI) method of sqliteopenhelper.Eg:@ OverridePublic String GetType (URI ){Final int match = surimatcher. Match (URI );Switch (MATCH){Case Notes:Case live_folder_notes:Return "Vnd. Android. cursor. DIR/vnd. myq. Note ";Case notes_id:Return "Vnd. Android. cursor. Item/vnd. myq. Note ";Default:Throw new illegalargumentex
capacity to the actual number of elements in the Queue.
6. Example of queue usageclassProgram {Static voidMain (string[] args) { //Create a queueQueue MyQ =NewQueue (); Myq.enqueue (" the");//QueueMyq.enqueue ("Quick"); Myq.enqueue ("Brown"); Myq.enqueue ("Fox"); Myq.enqueue (NULL);//add nullMyq.enqueue ("Fox");//add a repeating element//number and value of print queuesConsole.WriteLine ("MyQ
?
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
class Program { static void Main(string[] args) { // Create a queueQueue myQ = new Queue(); myQ.Enqueue("The");// Enter the teammyQ.Enqueue("quick"); myQ.Enqueue("brown"); myQ.Enqueue("fox"); myQ.Enqueue(null);// Add nullmyQ.Enqueue("fox");// Add duplicate elements// Print the number and value of the queueConsole.WriteLine("
need a first-in-first-out set, Use Queue// Creates and initializes a new queue.Queue myq = new Queue ();Myq. enqueue ("hello ");Myq. enqueue ("world ");Myq. enqueue ("! ");// Displays the properties and values of the queue.Console. writeline ("myq ");Console. writeline ("\
automatically manage appropriate thread pools and execute the queues you assign on the threads in the thread pool.
Therefore, dispatch_queue is not a thread, but an abstract design that allows you to stop thinking about thread terms.See the following example:
// Creating a dispatch queue is a lightweight operation.// Creating a thread = 512 KB// Creating a queue = 256 Bytes !// // We're going to create a serial queue.dispatch_queue_t myQ = dispatch_q
From: Use of http://apps.hi.baidu.com/share/detail/16127627STL queue # include # Include # Include /*
Header files: # include # Include Detailed usage:
Define the queue variable Check whether the null sample M. Empty () is 1, not 0;
Add M. Push () to the end of an existing element ()
Output the number of existing elements M. Size ()
Display the first element M. Front ()
Show the last element M. Back ()
Clear the first element M. POP ()
*/
Using namespace STD;
Int _ tmain (INT argc, _ tchar * ar
step, or it will be set to a user variable"
Example: declare MYQ int;
Example: declare myq int default 666;
Set the value of the variable:
Set variable name = value;
Gets the value of the variable:
Select variable name;
Create procedureMySet ()begin
DeclareMyaint; DeclareMyqint default 777; SelectMya,
. Attributes of Queue
Attribute name
Note
Count
Obtains the number of elements contained in a Queue.
5. Queue Method
Method Name
Note
Void Clear ()
Remove all objects from the Queue.
Bool Contains (object obj)
Determine whether an element is in the Queue.
Object Clone ()
Create a superficial copy of the Queue.
Void CopyTo (Array array, int index)
Copy the Queue element from the specified Array index to the existing one-dimensional Array.
Object Dequeue ()
Remove and return the
Enumerating through collections is inherently not a thread-safe process. Even when the collection is synchronized, other threads can still modify the collection, which causes the enumerator to throw an exception. To ensure thread safety during enumeration, you can lock the collection during the entire enumeration, or catch exceptions that are thrown due to changes made by other threads.
The following examples show how to synchronize the queue, how to determine whether the queue is synchronized,
to int or float,false values to 0 and 0.0,true to 1 and 1.0.floatf =1.7;intI =int(f);//I = 1///array initialization, you can pass in the constructor the value to initialize each of the corresponding values in the array. IVEC2 position[3] = ivec2[3]((0,0), (1,1), (2,2)); IVEC2 pos2[3] = ivec2[] ((3,3), (2,1), (3,1) );//The constructor can also initialize the struct body. Where the order and type should correspond. structSurface {intindex; VEC3 color; floatrotate;}; Surface Mysurface= Surface (3
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.