Skip to content

Commit 757823a

Browse files
committed
add pic
1 parent b4d8a0f commit 757823a

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

slice.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,29 @@ type slice struct {
1515

1616
slice 的底层结构定义非常直观,指向底层数组的指针,当前长度 len 和当前slice 的 cap。
1717

18+
```
19+
20+
[]int{1,3,4,5}
21+
22+
struct {
23+
array unsafe.Pointer --------------+
24+
len int |
25+
cap int |
26+
} |
27+
|
28+
v
29+
30+
+------|-------|------|------+-----+
31+
| | 1 | 3 | 4 | 5 |
32+
| | | | | |
33+
+------|-------|------|------+-----+
34+
[5]int
35+
36+
37+
38+
39+
```
40+
1841

1942

2043
> Written with [StackEdit](https://stackedit.io/).

0 commit comments

Comments
 (0)