| 1 | |
|---|
| 2 | :- protocol(queuep). |
|---|
| 3 | |
|---|
| 4 | :- info([ |
|---|
| 5 | version is 1.0, |
|---|
| 6 | author is 'Paulo Moura', |
|---|
| 7 | date is 2000/7/24, |
|---|
| 8 | comment is 'Queue protocol.']). |
|---|
| 9 | |
|---|
| 10 | :- public(empty/1). |
|---|
| 11 | :- mode(empty(@queue), zero_or_one). |
|---|
| 12 | :- info(empty/1, [ |
|---|
| 13 | comment is 'True if the queue is empty.', |
|---|
| 14 | argnames is ['Queue']]). |
|---|
| 15 | |
|---|
| 16 | :- public(head/2). |
|---|
| 17 | :- mode(head(+queue, ?term), zero_or_one). |
|---|
| 18 | :- info(head/2, [ |
|---|
| 19 | comment is 'Unifies Head with the first element of the queue.', |
|---|
| 20 | argnames is ['Queue', 'Head']]). |
|---|
| 21 | |
|---|
| 22 | :- public(join/3). |
|---|
| 23 | :- mode(join(@term, +queue, -queue), zero_or_one). |
|---|
| 24 | :- info(join/3, [ |
|---|
| 25 | comment is 'Adds the new element at the end of the queue.', |
|---|
| 26 | argnames is ['Element', 'Queue_in', 'Queue_out']]). |
|---|
| 27 | |
|---|
| 28 | :- public(join_all/3). |
|---|
| 29 | :- mode(join_all(+list, +queue, -queue), zero_or_one). |
|---|
| 30 | :- info(join_all/3, [ |
|---|
| 31 | comment is 'Adds the new elements at the end of the queue. The elements are added in the same order that they appear in the list.', |
|---|
| 32 | argnames is ['List', 'Queue_in', 'Queue_out']]). |
|---|
| 33 | |
|---|
| 34 | :- public(jump/3). |
|---|
| 35 | :- mode(jump(@term, +queue, -queue), zero_or_one). |
|---|
| 36 | :- info(jump/3, [ |
|---|
| 37 | comment is 'Adds the new element at the front of the queue.', |
|---|
| 38 | argnames is ['Element', 'Queue_in', 'Queue_out']]). |
|---|
| 39 | |
|---|
| 40 | :- public(jump_all/3). |
|---|
| 41 | :- mode(jump_all(+list, +queue, -queue), zero_or_one). |
|---|
| 42 | :- info(jump_all/3, [ |
|---|
| 43 | comment is 'Adds the new elements at the front of the queue. The elements are added in the same order that they appear in the list.', |
|---|
| 44 | argnames is ['Element', 'Queue_in', 'Queue_out']]). |
|---|
| 45 | |
|---|
| 46 | :- public(length/2). |
|---|
| 47 | :- mode(length(+queue, ?integer), zero_or_one). |
|---|
| 48 | :- info(length/2, |
|---|
| 49 | [comment is 'Queue length.', |
|---|
| 50 | argnames is ['Queue', 'Length']]). |
|---|
| 51 | |
|---|
| 52 | :- public(serve/3). |
|---|
| 53 | :- mode(serve(+queue, ?term, -queue), zero_or_one). |
|---|
| 54 | :- info(serve/3, [ |
|---|
| 55 | comment is 'Removes the first element of the queue for service.', |
|---|
| 56 | argnames is ['Queue_in', 'Head', 'Queue_out']]). |
|---|
| 57 | |
|---|
| 58 | :- public(as_list/2). |
|---|
| 59 | :- mode(as_list(+queue, -list), one). |
|---|
| 60 | :- info(as_list/2, |
|---|
| 61 | [comment is 'Converts a queue to a list.', |
|---|
| 62 | argnames is ['Queue', 'List']]). |
|---|
| 63 | |
|---|
| 64 | :- end_protocol. |
|---|