Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Gunosy.go #2 container
Search
Satoshi
September 25, 2014
Programming
79
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Gunosy.go #2 container
go lang study
Satoshi
September 25, 2014
More Decks by Satoshi
See All by Satoshi
高速な広告配信サーバの作り方のコツ
satoshi03
3
540
スケールしない広告サーバの作り方
satoshi03
0
260
Gunosy AdServerのデータ周りの話
satoshi03
2
3k
フルスクラッチで書いたアドサーバの開発・運用史
satoshi03
2
4.5k
Gunosy Go Lang Study #6 net net/http net/url
satoshi03
0
150
Other Decks in Programming
See All in Programming
設計次第でAIコードの読む量は減らせる / designing-for-code-reading
minodriven
34
15k
見えないものを探る要求要件定義に必要な基本的思考 / invisible-requirement-thinking
minodriven
14
6.8k
ゲームコントローラやキーボードのファームウェアをSwiftで書く
kishikawakatsumi
1
280
Vue Fes Japan の “作る側”に関わってみて
naokihaba
0
110
更なる可用性を求めて、5年間運用したKotlinのアプリケーションをGoでリプレイスする話
ken_tunc
0
450
モバイル交通系ICへのチャージ実例から考える、クロスプラットフォーム開発におけるiOS実機テスト設計とCI運用
yusuga
1
580
Agentic Software Factoryに、すごく賢いIF文を。 / super smart IF statement into the Agentic Software Factory.
rkaga
7
1.9k
R8 の設定見直しでアプリサイズ削減
andpad
0
180
Rでドレミ/Do-Re-Mi_with_R
florets1
0
120
Verilogで学ぶCPU自作入門.pdf
uyuki234
8
4k
AI時代のコードレビューは人に向けるな、仕組みに向けろ
texmeijin
5
3.5k
ハーネス設計入門 〜 基礎知識の整理から実務へのステップアップ 〜
kinopeee
20
21k
Featured
See All Featured
SEO Brein meetup: CTRL+C is not how to scale international SEO
lindahogenes
2
2.9k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
232
55k
Marketing Yourself as an Engineer | Alaka | Gurzu
gurzu
0
320
The Power of CSS Pseudo Elements
geoffreycrofte
82
6.6k
Primal Persuasion: How to Engage the Brain for Learning That Lasts
tmiket
0
490
GraphQLの誤解/rethinking-graphql
sonatard
75
12k
16th Malabo Montpellier Forum Presentation
akademiya2063
PRO
0
400
XXLCSS - How to scale CSS and keep your sanity
sugarenia
250
1.3M
Designing for humans not robots
tammielis
254
26k
Crafting Experiences
bethany
1
370
How to build a perfect <img>
jonoalderson
1
6.1k
WCS-LA-2024
lcolladotor
0
850
Transcript
Gunosy.go #2 container Gunosy Inc.
自己紹介 • 印南 聡志 (いんなみ さとし) • 6月にGunosyに入社
• Java/Ruby … 最近 Python/Go 始めました
Container • h?p://golang.org/pkg/container/ • データのまとまりを扱うためのパッケージ – List : 双方向連結リスト
– Ring : 循環リスト – Heap : 二分木構造リスト(用Interface)
List • 双方向連結リスト – 各エレメントが前後のエレメントへのリンク (ポインタ)を所持 – インサートは高速だがインデックス参照は不可 – ジェネリクスの機能はなし
• 型アサーションを使う必要がある Element value Element value Element value root next *Element prev *Element next *Element prev *Element
List – type Element • type Element – 双方向リストの要素(エレメント)、格納するデータ、
前後のリストのリンクを持つ – Value interface{} – func (*Element) Next – func (*Element) Prev
List – type List • type List
func New() *List func (l *List) Back() *Element func (l *List) Front() *Element func (l *List) Init() *List func (l *List) InsertATer(v interface{}, mark *Element) *Element func (l *List) InsertBefore(v interface{}, mark *Element) *Element func (l *List) Len() int func (l *List) MoveATer(e, mark *Element) func (l *List) MoveBefore(e, mark *Element) func (l *List) MoveToBack(e *Element) func (l *List) MoveToFront(e *Element) func (l *List) PushBack(v interface{}) *Element func (l *List) PushBackList(other *List) func (l *List) PushFront(v interface{}) *Element func (l *List) PushFrontList(other *List) func (l *List) Remove(e *Element) interface{}
List h?p://play.golang.org/p/7GnwWoC-‐_s 出力: 1 2 3
4
Ring • 循環リスト • どのリング要素のポインタもリング全体への参照と して使用可能 • (Javaのような)ジェネリクスの機能はなし
• 型アサー(ry prev *Ring next *Ring prev *Ring prev *Ring next *Ring next *Ring
Ring – type Ring func New(n int) *Ring
func (r *Ring) Do(f func(interface{})) func (r *Ring) Len() int func (r *Ring) Link(s *Ring) *Ring func (r *Ring) Move(n int) *Ring func (r *Ring) Next() *Ring func (r *Ring) Prev() *Ring func (r *Ring) Unlink(n int) *Ring
Ring h?p://play.golang.org/p/2SqEm4PGHT 出力: 要素数: 10 0 1
2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9
Heap • 二分木構造 • 取り出される値が常に最小になる – Init, Fix, Pop,
Push, Remove実行時にmin-‐heapが 走る • List, Ringとは異なり自身で定義した配列型に heap.interfaceを実装
Heap • 実装する必要のある関数 – func(Interface) Pop() – func(Interface) Push()
– func (Interface) Len() – func (Interface) Less() – func (Interface) Swap() デモ:h?p://play.golang.org/p/QIxb4gHIkW
まとめ • Container – データのまとまりを便利に扱うためのパッケージ • List : 双方向連結リスト
• Ring : 循環リスト • Heap : 2分木構造 – インサートが高速 – インデックスでの要素指定ができない