Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
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
GraphRAGのKnowledge Graphを 直接!見る/View-GraphRAG's-KnowledgeGraph-directly!
tyumugi1113
0
250
世界の中心で、AI(App Intents)をさけぶ ー App Intents中心設計の実践ガイド
touyou
0
170
[GoCon2026] When Goroutines Are Not Enough: Runtime Locality in High-Throughput Go
takehaya
4
630
MIZARU@SPAJAM2026 第二回予選
1901drama
0
110
AI Agent時代のリアーキテクチャ戦略と実践
hokaccha
2
760
Hello, Hiroshima Geospatial Data! — Exploring DoboX with Python
ra0kley
0
180
Swift愛好会100回記念 第1回を振り返る
jollyjoester
0
120
AIは賢い。でも実行環境は? CLIおじさんがAI時代に伝えたいこと ~ CLIおじさんがAI時代に伝えたいこと ~
curekoshimizu
1
170
数年滞っていたダークモード対応をおよそ2週間で完了させる
chigichan24
0
690
デプロイ直後のレイテンシスパイクを調べたら、 Railsの仕様にたどり着いた
nhsykym
0
110
PyConJP2026_wat_Python × Signal Processing: How to Draw Pictures with Sound Using Spectrogram Art
wat
0
680
Claude Codeを組織的に動かして月400PRを実現した話
happy_ryo
0
260
Featured
See All Featured
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
17k
Building a Scalable Design System with Sketch
lauravandoore
463
34k
The #1 spot is gone: here's how to win anyway
tamaranovitovic
3
1.2k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
49
10k
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
11
1k
Build your cross-platform service in a week with App Engine
jlugia
234
19k
Code Reviewing Like a Champion
maltzj
528
40k
Taking LLMs out of the black box: A practical guide to human-in-the-loop distillation
inesmontani
PRO
3
2.4k
GraphQLとの向き合い方2022年版
quramy
50
15k
Raft: Consensus for Rubyists
vanstee
141
7.7k
Color Theory Basics | Prateek | Gurzu
gurzu
0
460
Why Our Code Smells
bkeepers
PRO
340
58k
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分木構造 – インサートが高速 – インデックスでの要素指定ができない