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 @@ -501,31 +501,42 @@ func (f *SourceFile) Equals(other *SourceFile) bool {
501
501
f .RelativePath .EqualsTo (other .RelativePath )
502
502
}
503
503
504
+ // UniqueSourceFileQueue is a queue of SourceFile. A SourceFile
505
+ // can be pushed in the queue only once.
504
506
type UniqueSourceFileQueue struct {
505
507
queue []* SourceFile
506
508
curr int
507
509
}
508
510
511
+ // Len returns the number of element waiting in the queue
509
512
func (q * UniqueSourceFileQueue ) Len () int {
510
513
return len (q .queue ) - q .curr
511
514
}
512
515
516
+ // Push insert a new element in the queue
513
517
func (q * UniqueSourceFileQueue ) Push (value * SourceFile ) {
514
518
if ! q .Contains (value ) {
515
519
q .queue = append (q .queue , value )
516
520
}
517
521
}
518
522
523
+ // Pop return the first element in the queue or nil if the queue is empty
519
524
func (q * UniqueSourceFileQueue ) Pop () * SourceFile {
525
+ if q .Empty () {
526
+ return nil
527
+ }
520
528
res := q .queue [q .curr ]
521
529
q .curr ++
522
530
return res
523
531
}
524
532
533
+ // Empty returns true if the queue is empty
525
534
func (q * UniqueSourceFileQueue ) Empty () bool {
526
535
return q .Len () == 0
527
536
}
528
537
538
+ // Contains return true if the target elemen has been already added
539
+ // in the queue (even if the element has been alread popped out)
529
540
func (q * UniqueSourceFileQueue ) Contains (target * SourceFile ) bool {
530
541
for _ , elem := range q .queue {
531
542
if elem .Equals (target ) {
You can’t perform that action at this time.
0 commit comments