$.Data.Queue() - Class
Queue follows first in first out methodology. Queue data structure can be created in NedilJS using $.Data.Queue() class
Property
NameTypeDescription
containerArrayContainer which holds all the values in Queue
Methods
NameReturnsDescription
enqueue ( new_element )Inserts the new element into the queue
dequeue ()first elementRemoves the first element out of queue and returns the element
iterate ( handler_fn )Iterate over the Queue values and applies handler function to every value
Example 1
This example demonstrates Queue operations using $.Data.Queue class
JS HTML CSS
		$.domLoaded(function() {
		
			// create $.Data.Queue Object
			var q = new $.Data.Queue();
			
			// enqueue few elements
			q.enqueue(12);
			q.enqueue(57);
			q.enqueue(23);
			
			function showContent() {
				var cont = "";
				
				// iterate over the queue elements
				q.iterate(function(el) {
					cont += el + ", ";
				});
				
				// show queue
				$.get("#queue").text(cont);
			}
			
			showContent();			
			
			$.get("#btn1").on("click", function() {		
				var va = $.get("#inp").element().value.trim();
				
				// enqueue new element
				q.enqueue(va);		
				
				showContent();
			});		
			
			
			$.get("#btn2").on("click", function() {		
			
				// dequeue 
				var top = q.dequeue();
				
				$.get("#dequeue").html("Removed Element : " + top);
				showContent();
			});

		});						
						
<body>
	
	Queue
	<div id="queue"></div>

	<input type="text" id="inp" value="" />
	<input type="button" id="btn1" value="Enqueue" />

	<input type="button" id="btn2" value="Dequeue" />
	<div id="dequeue"></div>
	
</body>
		div {
		display : inline-block;
	}
	#inp {
		width : 30px;
	}
	
	#queue {
		border : 1px solid #555;
		padding : 5px;
	}
Result