dogfootman.com

  • 홈
  • 태그
  • 방명록

Slice 2

[Go] 슬라이스의 얕은 복사와 깊은 복사 (Shallow Copy and Deep Copy of Slices)

개요 슬라이스의 얕은 복사와 깊은 복사에 대해서 1. 얕은 복사 package main import ( "fmt" "sort" ) type obj struct { Name string Age int32 } func main() { list1 := []*obj{ {Name: "A", Age: 1}, {Name: "B", Age: 2}, {Name: "C", Age: 3}, } list2 := list1 sort.Slice(list2, func(i, j int) bool { return list2[i].Age < list2[j].Age }) fmt.Printf("List1 [%p]\n", list1) for _, item := range list1 { fmt.Printf("Name: %s, Age: %d [..

[Go] 2023.08.03

[Go] golang sort.Slice를 사용할때의 주의점 sort.SliceStable와의 차이점 (Important Considerations When Using golang sort.Slice and Differences from sort.SliceStable)

개요 sort.Slice를 사용했을때와 sort.SliceStable를 사용했을때의 결과를 비교 1. sort.Slice package main import ( "fmt" "sort" ) type Person struct { Name string Age int } func main() { people := []Person{ {"Alice", 30}, {"Bob", 30}, {"Charlie", 30}, {"David", 30}, {"Eve", 30}, {"Alice", 10}, {"Bob", 10}, {"Charlie", 10}, {"David", 10}, {"Eve", 10}, {"Alice", 20}, {"Bob", 20}, {"Charlie", 20}, {"David", 20}, {"Eve", 20..

[Go] 2023.07.27
이전
1
다음
더보기
  • View All Categories (13)
    • [Unity] (3)
      • [Unity 2D] (3)
    • [Go] (9)
    • [ETC] (1)

Tag

Unity, scroll wheel, Dependency, benchmark, Performance, go, struct, 고랭, pre-request script, Interface, Golang, Camera, deep copy, Slice, Unity 2D, mouse position, API, test, gob, cycle not allowed,

최근글과 인기글

  • 최근글
  • 인기글

방문자수Total

  • Today :
  • Yesterday :

Copyright © Kakao Corp. All rights reserved.

티스토리툴바