YAP 7.1.0

The following queue manipulation routines are available once included with the use_module(library(queues)) command. More...

Detailed Description

The following queue manipulation routines are available once included with the use_module(library(queues)) command.

Queues are implemented with difference lists

In this package, a queue is represented as a term Front-Back, where Front is a list and Back is a tail of that list, and is normally a variable join_queue will only work when the Back is a variable, the other routines will accept any tail The elements of the queue are the list difference, that is, all the elements starting at Front and stopping at Back Examples:

[a,b,c,d,e|Z]-Z has elements a,b,c,d,e [a,b,c,d,e]-[d,e] has elements a,b,c Z-Z has no elements [1,2,3]-[1,2,3] has no elements


Class Documentation

◆ make_queue/1

class make_queue/1

make_queue(+ Queue)

Creates a new empty queue It should only be used to create a new queue

◆ empty_queue/1

class empty_queue/1

empty_queue(+ Queue)

Tests whether the queue is empty

◆ head_queue/2

class head_queue/2

head_queue(+ Queue, ? Head)

Unifies Head with the first element of the queue

◆ join_queue/3

class join_queue/3

join_queue(+ Element, + OldQueue, - NewQueue)

Adds the new element at the end of the queue

◆ jump_queue/3

class jump_queue/3

jump_queue(+ Element, + OldQueue, - NewQueue)

Adds the new element at the front of the list

◆ length_queue/2

class length_queue/2

length_queue(+ Queue, - Length)

Counts the number of elements currently in the queue

◆ list_join_queue/3

class list_join_queue/3

list_join_queue(+ List, + OldQueue, - NewQueue)

Ads the new elements at the end of the queue

◆ list_jump_queue/3

class list_jump_queue/3

list_jump_queue(+ List, + OldQueue, + NewQueue)

Adds all the elements of List at the front of the queue

◆ list_to_queue/2

class list_to_queue/2

list_to_queue(+ List, - Queue)

Creates a new queue with the same elements as List

◆ queue_to_list/2

class queue_to_list/2

queue_to_list(+ Queue, - List)

Creates a new list with the same elements as Queue

◆ serve_queue/3

class serve_queue/3

serve_queue(+ OldQueue, + Head, - NewQueue)

Removes the first element of the queue for service