Queue.st
author Claus Gittinger <cg@exept.de>
Sat, 22 Jun 1996 18:52:25 +0200
changeset 396 88bd6136ee67
parent 350 93d5932c76e6
child 582 837907b61b6b
permissions -rw-r--r--
added #removeLast
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5
78a5b7c73feb Initial revision
claus
parents:
diff changeset
     1
"
78a5b7c73feb Initial revision
claus
parents:
diff changeset
     2
 COPYRIGHT (c) 1993 by Claus Gittinger
47
2fc2796fbec8 *** empty log message ***
claus
parents: 39
diff changeset
     3
	      All Rights Reserved
5
78a5b7c73feb Initial revision
claus
parents:
diff changeset
     4
78a5b7c73feb Initial revision
claus
parents:
diff changeset
     5
 This software is furnished under a license and may be used
78a5b7c73feb Initial revision
claus
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
78a5b7c73feb Initial revision
claus
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
78a5b7c73feb Initial revision
claus
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
78a5b7c73feb Initial revision
claus
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
78a5b7c73feb Initial revision
claus
parents:
diff changeset
    10
 hereby transferred.
78a5b7c73feb Initial revision
claus
parents:
diff changeset
    11
"
78a5b7c73feb Initial revision
claus
parents:
diff changeset
    12
30
f34b335ac2d7 *** empty log message ***
claus
parents: 14
diff changeset
    13
Collection subclass:#Queue
254
cccfa2590e6e documentation
Claus Gittinger <cg@exept.de>
parents: 131
diff changeset
    14
	instanceVariableNames:'contentsArray readPosition writePosition tally'
cccfa2590e6e documentation
Claus Gittinger <cg@exept.de>
parents: 131
diff changeset
    15
	classVariableNames:''
cccfa2590e6e documentation
Claus Gittinger <cg@exept.de>
parents: 131
diff changeset
    16
	poolDictionaries:''
cccfa2590e6e documentation
Claus Gittinger <cg@exept.de>
parents: 131
diff changeset
    17
	category:'Collections-Ordered'
5
78a5b7c73feb Initial revision
claus
parents:
diff changeset
    18
!
78a5b7c73feb Initial revision
claus
parents:
diff changeset
    19
396
88bd6136ee67 added #removeLast
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
    20
!Queue  class methodsFor:'documentation'!
30
f34b335ac2d7 *** empty log message ***
claus
parents: 14
diff changeset
    21
f34b335ac2d7 *** empty log message ***
claus
parents: 14
diff changeset
    22
copyright
f34b335ac2d7 *** empty log message ***
claus
parents: 14
diff changeset
    23
"
f34b335ac2d7 *** empty log message ***
claus
parents: 14
diff changeset
    24
 COPYRIGHT (c) 1993 by Claus Gittinger
47
2fc2796fbec8 *** empty log message ***
claus
parents: 39
diff changeset
    25
	      All Rights Reserved
5
78a5b7c73feb Initial revision
claus
parents:
diff changeset
    26
30
f34b335ac2d7 *** empty log message ***
claus
parents: 14
diff changeset
    27
 This software is furnished under a license and may be used
f34b335ac2d7 *** empty log message ***
claus
parents: 14
diff changeset
    28
 only in accordance with the terms of that license and with the
f34b335ac2d7 *** empty log message ***
claus
parents: 14
diff changeset
    29
 inclusion of the above copyright notice.   This software may not
f34b335ac2d7 *** empty log message ***
claus
parents: 14
diff changeset
    30
 be provided or otherwise made available to, or used by, any
f34b335ac2d7 *** empty log message ***
claus
parents: 14
diff changeset
    31
 other person.  No title to or ownership of the software is
f34b335ac2d7 *** empty log message ***
claus
parents: 14
diff changeset
    32
 hereby transferred.
f34b335ac2d7 *** empty log message ***
claus
parents: 14
diff changeset
    33
"
f34b335ac2d7 *** empty log message ***
claus
parents: 14
diff changeset
    34
!
f34b335ac2d7 *** empty log message ***
claus
parents: 14
diff changeset
    35
f34b335ac2d7 *** empty log message ***
claus
parents: 14
diff changeset
    36
documentation
f34b335ac2d7 *** empty log message ***
claus
parents: 14
diff changeset
    37
"
74
claus
parents: 50
diff changeset
    38
    Queues provides a simple implementation of a queue, where
claus
parents: 50
diff changeset
    39
    elements are enterred at one end and removed at the other.
claus
parents: 50
diff changeset
    40
    Access protocol is somewhat like a streams protocol, i.e. access
claus
parents: 50
diff changeset
    41
    is by #nextPut: and #next.
claus
parents: 50
diff changeset
    42
    The queue is created with a size argument, defining how many elements
claus
parents: 50
diff changeset
    43
    are to be stored. It will report an error if the queue ever becomes full
claus
parents: 50
diff changeset
    44
    and another element is to be added. Likewise, it will report an error
claus
parents: 50
diff changeset
    45
    if its empty and an element is to be removed.
claus
parents: 50
diff changeset
    46
claus
parents: 50
diff changeset
    47
    It is not safe when two processes access Queues simultanously,
claus
parents: 50
diff changeset
    48
    since accesses to the internals are not protected against process-switches.
claus
parents: 50
diff changeset
    49
claus
parents: 50
diff changeset
    50
    See SharedQueue for a class which is safe with processes and blocks
claus
parents: 50
diff changeset
    51
    on write when full or on read when empty.
254
cccfa2590e6e documentation
Claus Gittinger <cg@exept.de>
parents: 131
diff changeset
    52
cccfa2590e6e documentation
Claus Gittinger <cg@exept.de>
parents: 131
diff changeset
    53
    [author:]
cccfa2590e6e documentation
Claus Gittinger <cg@exept.de>
parents: 131
diff changeset
    54
        Claus Gittinger
30
f34b335ac2d7 *** empty log message ***
claus
parents: 14
diff changeset
    55
"
f34b335ac2d7 *** empty log message ***
claus
parents: 14
diff changeset
    56
! !
5
78a5b7c73feb Initial revision
claus
parents:
diff changeset
    57
396
88bd6136ee67 added #removeLast
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
    58
!Queue  class methodsFor:'instance creation'!
5
78a5b7c73feb Initial revision
claus
parents:
diff changeset
    59
122
c379960395f6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
    60
new
c379960395f6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
    61
    "return a new queue with space for some elements"
c379960395f6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
    62
c379960395f6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
    63
    ^ self new:50
c379960395f6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
    64
!
c379960395f6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
    65
5
78a5b7c73feb Initial revision
claus
parents:
diff changeset
    66
new:size
78a5b7c73feb Initial revision
claus
parents:
diff changeset
    67
    "return a new queue with space for size elements"
78a5b7c73feb Initial revision
claus
parents:
diff changeset
    68
78a5b7c73feb Initial revision
claus
parents:
diff changeset
    69
    ^ super new init:size
78a5b7c73feb Initial revision
claus
parents:
diff changeset
    70
78a5b7c73feb Initial revision
claus
parents:
diff changeset
    71
    "
78a5b7c73feb Initial revision
claus
parents:
diff changeset
    72
     |q|
78a5b7c73feb Initial revision
claus
parents:
diff changeset
    73
78a5b7c73feb Initial revision
claus
parents:
diff changeset
    74
     q := Queue new.
39
47fc4acc24db added do:, nextPutAll:
claus
parents: 33
diff changeset
    75
     (1 to:5) do:[:i | q nextPut:i].
47fc4acc24db added do:, nextPutAll:
claus
parents: 33
diff changeset
    76
     Transcript show:(q next); space.
47fc4acc24db added do:, nextPutAll:
claus
parents: 33
diff changeset
    77
     Transcript show:(q next); space.
47fc4acc24db added do:, nextPutAll:
claus
parents: 33
diff changeset
    78
     Transcript show:(q next); space.
47fc4acc24db added do:, nextPutAll:
claus
parents: 33
diff changeset
    79
     Transcript show:(q next); space.
47fc4acc24db added do:, nextPutAll:
claus
parents: 33
diff changeset
    80
     q nextPutAll:(6 to:10).
47fc4acc24db added do:, nextPutAll:
claus
parents: 33
diff changeset
    81
     Transcript show:(q next); space.
47fc4acc24db added do:, nextPutAll:
claus
parents: 33
diff changeset
    82
     Transcript show:(q next); space.
47fc4acc24db added do:, nextPutAll:
claus
parents: 33
diff changeset
    83
     Transcript show:(q next); space.
47fc4acc24db added do:, nextPutAll:
claus
parents: 33
diff changeset
    84
     Transcript show:(q next); space.
47fc4acc24db added do:, nextPutAll:
claus
parents: 33
diff changeset
    85
     Transcript show:(q next); space.
47fc4acc24db added do:, nextPutAll:
claus
parents: 33
diff changeset
    86
     Transcript show:(q next); space.
47fc4acc24db added do:, nextPutAll:
claus
parents: 33
diff changeset
    87
     Transcript show:(q next); space.
47fc4acc24db added do:, nextPutAll:
claus
parents: 33
diff changeset
    88
     Transcript show:(q next); space.
47fc4acc24db added do:, nextPutAll:
claus
parents: 33
diff changeset
    89
     Transcript show:(q next); space.
350
93d5932c76e6 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 254
diff changeset
    90
     Transcript showCR:(q next).
5
78a5b7c73feb Initial revision
claus
parents:
diff changeset
    91
    "
78a5b7c73feb Initial revision
claus
parents:
diff changeset
    92
! !
78a5b7c73feb Initial revision
claus
parents:
diff changeset
    93
78a5b7c73feb Initial revision
claus
parents:
diff changeset
    94
!Queue methodsFor:'accessing'!
78a5b7c73feb Initial revision
claus
parents:
diff changeset
    95
78a5b7c73feb Initial revision
claus
parents:
diff changeset
    96
next
39
47fc4acc24db added do:, nextPutAll:
claus
parents: 33
diff changeset
    97
    "return the next value in the queue; 
47fc4acc24db added do:, nextPutAll:
claus
parents: 33
diff changeset
    98
     Return nil, if the queue is empty"
5
78a5b7c73feb Initial revision
claus
parents:
diff changeset
    99
47
2fc2796fbec8 *** empty log message ***
claus
parents: 39
diff changeset
   100
    |value pos "{ Class: SmallInteger }"|
5
78a5b7c73feb Initial revision
claus
parents:
diff changeset
   101
78a5b7c73feb Initial revision
claus
parents:
diff changeset
   102
    (tally == 0) ifTrue:[^ nil].
47
2fc2796fbec8 *** empty log message ***
claus
parents: 39
diff changeset
   103
2fc2796fbec8 *** empty log message ***
claus
parents: 39
diff changeset
   104
    pos := readPosition.
2fc2796fbec8 *** empty log message ***
claus
parents: 39
diff changeset
   105
2fc2796fbec8 *** empty log message ***
claus
parents: 39
diff changeset
   106
    value := contentsArray at:pos.
2fc2796fbec8 *** empty log message ***
claus
parents: 39
diff changeset
   107
    pos := pos + 1.
2fc2796fbec8 *** empty log message ***
claus
parents: 39
diff changeset
   108
    pos > contentsArray size ifTrue:[pos := 1].
2fc2796fbec8 *** empty log message ***
claus
parents: 39
diff changeset
   109
    readPosition := pos.
5
78a5b7c73feb Initial revision
claus
parents:
diff changeset
   110
    tally := tally - 1.
78a5b7c73feb Initial revision
claus
parents:
diff changeset
   111
    ^ value
78a5b7c73feb Initial revision
claus
parents:
diff changeset
   112
!
78a5b7c73feb Initial revision
claus
parents:
diff changeset
   113
78a5b7c73feb Initial revision
claus
parents:
diff changeset
   114
nextPut:anObject
78a5b7c73feb Initial revision
claus
parents:
diff changeset
   115
    "enter anObject into the queue - if the queue is full, report an error"
78a5b7c73feb Initial revision
claus
parents:
diff changeset
   116
47
2fc2796fbec8 *** empty log message ***
claus
parents: 39
diff changeset
   117
    |sz pos "{ Class: SmallInteger }" |
2fc2796fbec8 *** empty log message ***
claus
parents: 39
diff changeset
   118
2fc2796fbec8 *** empty log message ***
claus
parents: 39
diff changeset
   119
    sz := contentsArray size.
2fc2796fbec8 *** empty log message ***
claus
parents: 39
diff changeset
   120
    pos := writePosition.
2fc2796fbec8 *** empty log message ***
claus
parents: 39
diff changeset
   121
2fc2796fbec8 *** empty log message ***
claus
parents: 39
diff changeset
   122
    (tally == sz) ifTrue:[
2fc2796fbec8 *** empty log message ***
claus
parents: 39
diff changeset
   123
	self error:'queue is full'.
2fc2796fbec8 *** empty log message ***
claus
parents: 39
diff changeset
   124
	^ self
5
78a5b7c73feb Initial revision
claus
parents:
diff changeset
   125
    ].
47
2fc2796fbec8 *** empty log message ***
claus
parents: 39
diff changeset
   126
2fc2796fbec8 *** empty log message ***
claus
parents: 39
diff changeset
   127
    contentsArray at:pos put:anObject.
2fc2796fbec8 *** empty log message ***
claus
parents: 39
diff changeset
   128
    pos := pos + 1.
2fc2796fbec8 *** empty log message ***
claus
parents: 39
diff changeset
   129
    pos > sz ifTrue:[pos := 1].
2fc2796fbec8 *** empty log message ***
claus
parents: 39
diff changeset
   130
    writePosition := pos.
5
78a5b7c73feb Initial revision
claus
parents:
diff changeset
   131
    tally := tally + 1
39
47fc4acc24db added do:, nextPutAll:
claus
parents: 33
diff changeset
   132
!
47fc4acc24db added do:, nextPutAll:
claus
parents: 33
diff changeset
   133
47fc4acc24db added do:, nextPutAll:
claus
parents: 33
diff changeset
   134
nextPutAll:aCollection
47fc4acc24db added do:, nextPutAll:
claus
parents: 33
diff changeset
   135
    "enter all elements from aCollection into the queue."
47fc4acc24db added do:, nextPutAll:
claus
parents: 33
diff changeset
   136
47fc4acc24db added do:, nextPutAll:
claus
parents: 33
diff changeset
   137
    aCollection do:[:element | self nextPut:element]
122
c379960395f6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   138
!
c379960395f6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   139
c379960395f6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   140
peek
c379960395f6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   141
    "return the next value in the queue without removing it.
c379960395f6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   142
     If the queue is empty, return nil."
c379960395f6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   143
c379960395f6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   144
    (tally == 0) ifTrue:[^ nil].
c379960395f6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   145
    ^ contentsArray at:readPosition.
396
88bd6136ee67 added #removeLast
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
   146
!
88bd6136ee67 added #removeLast
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
   147
88bd6136ee67 added #removeLast
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
   148
removeLast
88bd6136ee67 added #removeLast
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
   149
    "return the last value in the queue; 
88bd6136ee67 added #removeLast
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
   150
     Return nil, if the queue is empty"
88bd6136ee67 added #removeLast
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
   151
88bd6136ee67 added #removeLast
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
   152
    |value pos "{ Class: SmallInteger }"|
88bd6136ee67 added #removeLast
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
   153
88bd6136ee67 added #removeLast
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
   154
    (tally == 0) ifTrue:[^ nil].
88bd6136ee67 added #removeLast
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
   155
88bd6136ee67 added #removeLast
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
   156
    pos := writePosition.
88bd6136ee67 added #removeLast
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
   157
    pos == 1 ifTrue:[
88bd6136ee67 added #removeLast
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
   158
        pos := contentsArray size
88bd6136ee67 added #removeLast
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
   159
    ] ifFalse:[
88bd6136ee67 added #removeLast
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
   160
        pos := pos - 1.
88bd6136ee67 added #removeLast
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
   161
    ].
88bd6136ee67 added #removeLast
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
   162
88bd6136ee67 added #removeLast
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
   163
    value := contentsArray at:pos.
88bd6136ee67 added #removeLast
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
   164
    writePosition := pos.
88bd6136ee67 added #removeLast
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
   165
    tally := tally - 1.
88bd6136ee67 added #removeLast
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
   166
    ^ value
88bd6136ee67 added #removeLast
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
   167
88bd6136ee67 added #removeLast
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
   168
    "Created: 22.6.1996 / 18:49:41 / cg"
39
47fc4acc24db added do:, nextPutAll:
claus
parents: 33
diff changeset
   169
! !
47fc4acc24db added do:, nextPutAll:
claus
parents: 33
diff changeset
   170
50
983d862738c1 *** empty log message ***
claus
parents: 47
diff changeset
   171
!Queue methodsFor:'enumerating'!
39
47fc4acc24db added do:, nextPutAll:
claus
parents: 33
diff changeset
   172
47fc4acc24db added do:, nextPutAll:
claus
parents: 33
diff changeset
   173
do:aBlock
47fc4acc24db added do:, nextPutAll:
claus
parents: 33
diff changeset
   174
    "evaluate the argument, aBlock for each element in the queue"
47fc4acc24db added do:, nextPutAll:
claus
parents: 33
diff changeset
   175
47fc4acc24db added do:, nextPutAll:
claus
parents: 33
diff changeset
   176
    |pos endPos|
47fc4acc24db added do:, nextPutAll:
claus
parents: 33
diff changeset
   177
47fc4acc24db added do:, nextPutAll:
claus
parents: 33
diff changeset
   178
    pos := readPosition.
47fc4acc24db added do:, nextPutAll:
claus
parents: 33
diff changeset
   179
    endPos := writePosition.
47fc4acc24db added do:, nextPutAll:
claus
parents: 33
diff changeset
   180
    1 to:tally do:[:i |
47
2fc2796fbec8 *** empty log message ***
claus
parents: 39
diff changeset
   181
	aBlock value:(contentsArray at:pos).
2fc2796fbec8 *** empty log message ***
claus
parents: 39
diff changeset
   182
	pos := pos + 1.
2fc2796fbec8 *** empty log message ***
claus
parents: 39
diff changeset
   183
	pos > contentsArray size ifTrue:[
2fc2796fbec8 *** empty log message ***
claus
parents: 39
diff changeset
   184
	    pos := 1
2fc2796fbec8 *** empty log message ***
claus
parents: 39
diff changeset
   185
	]
39
47fc4acc24db added do:, nextPutAll:
claus
parents: 33
diff changeset
   186
    ]
5
78a5b7c73feb Initial revision
claus
parents:
diff changeset
   187
! !
78a5b7c73feb Initial revision
claus
parents:
diff changeset
   188
122
c379960395f6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   189
!Queue methodsFor:'initialization'!
c379960395f6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   190
c379960395f6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   191
init:size
c379960395f6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   192
    "initialize the receiver for size entries"
c379960395f6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   193
c379960395f6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   194
    contentsArray := Array new:size.
c379960395f6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   195
    readPosition := writePosition := 1.
c379960395f6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   196
    tally := 0.
c379960395f6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   197
! !
c379960395f6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   198
5
78a5b7c73feb Initial revision
claus
parents:
diff changeset
   199
!Queue methodsFor:'queries'!
78a5b7c73feb Initial revision
claus
parents:
diff changeset
   200
122
c379960395f6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   201
capacity 
c379960395f6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   202
    "return the number of elements the queue can hold"
c379960395f6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   203
c379960395f6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   204
    ^ contentsArray size
c379960395f6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   205
!
c379960395f6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   206
30
f34b335ac2d7 *** empty log message ***
claus
parents: 14
diff changeset
   207
isEmpty
f34b335ac2d7 *** empty log message ***
claus
parents: 14
diff changeset
   208
    "return true, if there are no elements in the queue"
f34b335ac2d7 *** empty log message ***
claus
parents: 14
diff changeset
   209
f34b335ac2d7 *** empty log message ***
claus
parents: 14
diff changeset
   210
    ^ tally == 0
f34b335ac2d7 *** empty log message ***
claus
parents: 14
diff changeset
   211
!
f34b335ac2d7 *** empty log message ***
claus
parents: 14
diff changeset
   212
f34b335ac2d7 *** empty log message ***
claus
parents: 14
diff changeset
   213
isFull
f34b335ac2d7 *** empty log message ***
claus
parents: 14
diff changeset
   214
    "return true, if the queue is full i.e. if writing is not
f34b335ac2d7 *** empty log message ***
claus
parents: 14
diff changeset
   215
     possible"
f34b335ac2d7 *** empty log message ***
claus
parents: 14
diff changeset
   216
f34b335ac2d7 *** empty log message ***
claus
parents: 14
diff changeset
   217
    ^ tally == contentsArray size
f34b335ac2d7 *** empty log message ***
claus
parents: 14
diff changeset
   218
!
f34b335ac2d7 *** empty log message ***
claus
parents: 14
diff changeset
   219
5
78a5b7c73feb Initial revision
claus
parents:
diff changeset
   220
size
78a5b7c73feb Initial revision
claus
parents:
diff changeset
   221
    "return the number of elements in the queue"
78a5b7c73feb Initial revision
claus
parents:
diff changeset
   222
78a5b7c73feb Initial revision
claus
parents:
diff changeset
   223
    ^ tally
122
c379960395f6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   224
! !
81
claus
parents: 75
diff changeset
   225
396
88bd6136ee67 added #removeLast
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
   226
!Queue  class methodsFor:'documentation'!
131
19e548711b65 version at the end
Claus Gittinger <cg@exept.de>
parents: 122
diff changeset
   227
19e548711b65 version at the end
Claus Gittinger <cg@exept.de>
parents: 122
diff changeset
   228
version
396
88bd6136ee67 added #removeLast
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
   229
    ^ '$Header: /cvs/stx/stx/libbasic2/Queue.st,v 1.18 1996-06-22 16:52:09 cg Exp $'
131
19e548711b65 version at the end
Claus Gittinger <cg@exept.de>
parents: 122
diff changeset
   230
! !