mirror of
https://github.com/duke-git/lancet.git
synced 2026-02-14 01:32:27 +08:00
doc: add doc for FindLast
This commit is contained in:
@@ -40,6 +40,7 @@ import (
|
|||||||
- [ForEach](#ForEach)
|
- [ForEach](#ForEach)
|
||||||
- [Reduce](#Reduce)
|
- [Reduce](#Reduce)
|
||||||
- [FindFirst](#FindFirst)
|
- [FindFirst](#FindFirst)
|
||||||
|
- [FindLast](#FindLast)
|
||||||
- [Max](#Max)
|
- [Max](#Max)
|
||||||
- [Min](#Min)
|
- [Min](#Min)
|
||||||
- [AllMatch](#AllMatch)
|
- [AllMatch](#AllMatch)
|
||||||
@@ -667,6 +668,38 @@ func main() {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### <span id="FindLast">FindLast</span>
|
||||||
|
|
||||||
|
<p>Returns the last element of this stream and true, or zero value and false if the stream is empty.</p>
|
||||||
|
|
||||||
|
<b>Signature:</b>
|
||||||
|
|
||||||
|
```go
|
||||||
|
func (s stream[T]) FindLast() (T, bool)
|
||||||
|
```
|
||||||
|
|
||||||
|
<b>Example:</b>
|
||||||
|
|
||||||
|
```go
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"github.com/duke-git/lancet/v2/stream"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
original := FromSlice([]int{3, 2, 1})
|
||||||
|
|
||||||
|
result, ok := original.FindLast()
|
||||||
|
|
||||||
|
fmt.Println(result)
|
||||||
|
fmt.Println(ok)
|
||||||
|
|
||||||
|
// Output:
|
||||||
|
// 1
|
||||||
|
// true
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
### <span id="Max">Max</span>
|
### <span id="Max">Max</span>
|
||||||
|
|
||||||
<p>Returns the maximum element of this stream according to the provided less function. less fuction: a > b</p>
|
<p>Returns the maximum element of this stream according to the provided less function. less fuction: a > b</p>
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ import (
|
|||||||
- [ForEach](#ForEach)
|
- [ForEach](#ForEach)
|
||||||
- [Reduce](#Reduce)
|
- [Reduce](#Reduce)
|
||||||
- [FindFirst](#FindFirst)
|
- [FindFirst](#FindFirst)
|
||||||
|
- [FindLast](#FindLast)
|
||||||
- [Max](#Max)
|
- [Max](#Max)
|
||||||
- [Min](#Min)
|
- [Min](#Min)
|
||||||
- [AllMatch](#AllMatch)
|
- [AllMatch](#AllMatch)
|
||||||
@@ -667,6 +668,38 @@ func main() {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### <span id="FindLast">FindLast</span>
|
||||||
|
|
||||||
|
<p>返回此stream最后一个元素和true,如果stream为空,则返回零值和false。</p>
|
||||||
|
|
||||||
|
<b>函数签名:</b>
|
||||||
|
|
||||||
|
```go
|
||||||
|
func (s stream[T]) FindLast() (T, bool)
|
||||||
|
```
|
||||||
|
|
||||||
|
<b>示例:</b>
|
||||||
|
|
||||||
|
```go
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"github.com/duke-git/lancet/v2/stream"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
original := FromSlice([]int{3, 2, 1})
|
||||||
|
|
||||||
|
result, ok := original.FindLast()
|
||||||
|
|
||||||
|
fmt.Println(result)
|
||||||
|
fmt.Println(ok)
|
||||||
|
|
||||||
|
// Output:
|
||||||
|
// 1
|
||||||
|
// true
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
### <span id="Max">Max</span>
|
### <span id="Max">Max</span>
|
||||||
|
|
||||||
<p>根据提供的less函数返回stream的最大元素。less 函数: a > b</p>
|
<p>根据提供的less函数返回stream的最大元素。less 函数: a > b</p>
|
||||||
|
|||||||
Reference in New Issue
Block a user