[//000000001]: # (struct::queue \- Tcl Data Structures)
[//000000002]: # (Generated from file 'queue\.man' by tcllib/doctools with format 'markdown')
[//000000003]: # (struct::queue\(n\) 1\.4\.5 tcllib "Tcl Data Structures")
[ Main Table Of Contents | Table Of Contents | Keyword Index | Categories | Modules | Applications ]
# NAME
struct::queue \- Create and manipulate queue objects
# Table Of Contents
- [Table Of Contents](#toc)
- [Synopsis](#synopsis)
- [Description](#section1)
- [Bugs, Ideas, Feedback](#section2)
- [Keywords](#keywords)
- [Category](#category)
# SYNOPSIS
package require Tcl 8\.4
package require struct::queue ?1\.4\.5?
[*queueName* __option__ ?*arg arg \.\.\.*?](#1)
[*queueName* __clear__](#2)
[*queueName* __destroy__](#3)
[*queueName* __get__ ?*count*?](#4)
[*queueName* __peek__ ?*count*?](#5)
[*queueName* __put__ *item* ?*item \.\.\.*?](#6)
[*queueName* __unget__ *item*](#7)
[*queueName* __size__](#8)
# DESCRIPTION
The __::struct__ namespace contains a commands for processing finite queues\.
It exports a single command, __::struct::queue__\. All functionality provided
here can be reached through a subcommand of this command\.
*Note:* As of version 1\.4\.1 of this package a critcl based C implementation is
available\. This implementation however requires Tcl 8\.4 to run\.
The __::struct::queue__ command creates a new queue object with an
associated global Tcl command whose name is *queueName*\. This command may be
used to invoke various operations on the queue\. It has the following general
form:
- *queueName* __option__ ?*arg arg \.\.\.*?
*Option* and the *arg*s determine the exact behavior of the command\. The
following commands are possible for queue objects:
- *queueName* __clear__
Remove all items from the queue\.
- *queueName* __destroy__
Destroy the queue, including its storage space and associated command\.
- *queueName* __get__ ?*count*?
Return the front *count* items of the queue and remove them from the
queue\. If *count* is not specified, it defaults to 1\. If *count* is 1,
the result is a simple string; otherwise, it is a list\. If specified,
*count* must be greater than or equal to 1\. If there are not enough items
in the queue to fulfull the request, this command will throw an error\.
- *queueName* __peek__ ?*count*?
Return the front *count* items of the queue, without removing them from
the queue\. If *count* is not specified, it defaults to 1\. If *count* is
1, the result is a simple string; otherwise, it is a list\. If specified,
*count* must be greater than or equal to 1\. If there are not enough items
in the queue to fulfull the request, this command will throw an error\.
- *queueName* __put__ *item* ?*item \.\.\.*?
Put the *item* or items specified into the queue\. If more than one
*item* is given, they will be added in the order they are listed\.
- *queueName* __unget__ *item*
Put the *item* into the queue, at the front, i\.e\. before any other items
already in the queue\. This makes this operation the complement to the method
__get__\.
- *queueName* __size__
Return the number of items in the queue\.
# Bugs, Ideas, Feedback
This document, and the package it describes, will undoubtedly contain bugs and
other problems\. Please report such in the category *struct :: queue* of the
[Tcllib Trackers](http://core\.tcl\.tk/tcllib/reportlist)\. Please also report
any ideas for enhancements you may have for either package and/or documentation\.
When proposing code changes, please provide *unified diffs*, i\.e the output of
__diff \-u__\.
Note further that *attachments* are strongly preferred over inlined patches\.
Attachments can be made by going to the __Edit__ form of the ticket
immediately after its creation, and then using the left\-most button in the
secondary navigation bar\.
# KEYWORDS
[graph](\.\./\.\./\.\./\.\./index\.md\#graph), [list](\.\./\.\./\.\./\.\./index\.md\#list),
[matrix](\.\./\.\./\.\./\.\./index\.md\#matrix),
[pool](\.\./\.\./\.\./\.\./index\.md\#pool),
[prioqueue](\.\./\.\./\.\./\.\./index\.md\#prioqueue),
[record](\.\./\.\./\.\./\.\./index\.md\#record), [set](\.\./\.\./\.\./\.\./index\.md\#set),
[skiplist](\.\./\.\./\.\./\.\./index\.md\#skiplist),
[stack](\.\./\.\./\.\./\.\./index\.md\#stack), [tree](\.\./\.\./\.\./\.\./index\.md\#tree)
# CATEGORY
Data structures