File tree Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -483,31 +483,42 @@ func (f *SourceFile) Equals(other *SourceFile) bool {
483
483
f .RelativePath .EqualsTo (other .RelativePath )
484
484
}
485
485
486
+ // UniqueSourceFileQueue is a queue of SourceFile. A SourceFile
487
+ // can be pushed in the queue only once.
486
488
type UniqueSourceFileQueue struct {
487
489
queue []* SourceFile
488
490
curr int
489
491
}
490
492
493
+ // Len returns the number of element waiting in the queue
491
494
func (q * UniqueSourceFileQueue ) Len () int {
492
495
return len (q .queue ) - q .curr
493
496
}
494
497
498
+ // Push insert a new element in the queue
495
499
func (q * UniqueSourceFileQueue ) Push (value * SourceFile ) {
496
500
if ! q .Contains (value ) {
497
501
q .queue = append (q .queue , value )
498
502
}
499
503
}
500
504
505
+ // Pop return the first element in the queue or nil if the queue is empty
501
506
func (q * UniqueSourceFileQueue ) Pop () * SourceFile {
507
+ if q .Empty () {
508
+ return nil
509
+ }
502
510
res := q .queue [q .curr ]
503
511
q .curr ++
504
512
return res
505
513
}
506
514
515
+ // Empty returns true if the queue is empty
507
516
func (q * UniqueSourceFileQueue ) Empty () bool {
508
517
return q .Len () == 0
509
518
}
510
519
520
+ // Contains return true if the target elemen has been already added
521
+ // in the queue (even if the element has been alread popped out)
511
522
func (q * UniqueSourceFileQueue ) Contains (target * SourceFile ) bool {
512
523
for _ , elem := range q .queue {
513
524
if elem .Equals (target ) {
You can’t perform that action at this time.
0 commit comments