⛓️
Blockchain
  • Start!
  • Go_lang
    • Tutorial
    • 1. Banking
    • 2. Dictionary
    • 3. URL Checker
    • Useful Methods - Slice
    • Useful data structure
  • RUST
    • Start
    • Basic
    • Basic Programming Concepts
      • Variables and Mutability
  • Bitcoin
    • Start
    • Introduction
    • Transactions
  • GO-BITCOIN
    • Start
    • 1. Blocks & Blockchain
    • 2. Proof of work
    • 3. BadgerDB
    • 4. Transactions
    • 5. Wallet
    • 6. Adding Digital Signatures
  • COSMOS
    • 코스모스 SDK
    • 코스모스 SDK 실습 - nameservice
    • 코스모스 허브는 어떻게 사용하는가?
    • 코스모스 허브, 금융의 역사를 다시 쓰다
    • Tendermint
      • ABCI
      • Messages
  • Cosmos Tutorial
    • Tutorials
    • 1. Blog
    • Nameservice
    • [Starport] Escrow Account: Scavenge
    • [Starport] Inter-Blockchain Communication: Basics
    • Create an IBC Interchain Exchange module
      • Introduction
      • App Design
      • Initialize the Blockchain
      • Create the Order Book
  • Ethereum
    • Start
    • Gas
    • Oracle Problem
  • consensus
    • DPoS
    • PBFT
    • Network model
  • cryptosystem
    • 대칭키 암호
    • IPFS
  • Social token
    • Rally
    • DeSo
      • Bitclout
      • Deso: The Decentralized Social Network
      • Setting Up Your Dev Environment
      • Deso Code Walkthrough
      • Web3 Will Not Be Built on Smart Contracts
  • 재윤TV
    • Start
    • 유니스왑에 대해서 아라보자
      • Concept
      • V2 백서 분석
      • V2 코드 분석
Powered by GitBook
On this page
  • Set
  • Slice of map

Was this helpful?

  1. Go_lang

Useful data structure

Set

Go lang에는 set이 없지만 비슷하게 만들어 사용할 수 있다.

func setAdd(s map[int]bool, v int) map[int]bool {
	s[v] = true
	return s
}

func main() {
	s := make(map[int]bool)
	s = setAdd(s, 1)
	s = setAdd(s, 2)
	s = setAdd(s, 3)
	s = setAdd(s, 2)
	fmt.Println(s)
	delete(s, 3)
	fmt.Println(s)
}
map[1:true 2:true 3:true]
map[1:true 2:true]

Slice of map

// 길이 3짜리 slice 안에 map[int]bool 이 존재.
m := make([]map[int]bool, 3, 3)
// map을 초기화해줘야 사용할 수 있다. 
for i := range m{
    m = map[int]bool{}
}

PreviousUseful Methods - SliceNextStart

Last updated 3 years ago

Was this helpful?