This repository has been archived by the owner on Sep 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
410 additions
and
325 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package uniq2 | ||
|
||
/* | ||
AdjacentUniqer is an implementation of uniqer for adjacent lines. | ||
*/ | ||
type AdjacentUniqer struct { | ||
prev string | ||
firstLine bool | ||
} | ||
|
||
/* | ||
NewAdjacentUniqer creates an instance of AdjacentUniqer. | ||
*/ | ||
func NewAdjacentUniqer() *AdjacentUniqer { | ||
return &AdjacentUniqer{prev: "", firstLine: true} | ||
} | ||
|
||
/* | ||
StreamLine tries to remove the duplicated line. | ||
*/ | ||
func (au *AdjacentUniqer) StreamLine(line string) bool { | ||
if au.firstLine { | ||
au.prev = line | ||
au.firstLine = false | ||
return true | ||
} | ||
if au.prev == line { | ||
return false | ||
} | ||
au.prev = line | ||
return true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.