forked from zxh0/jvmgo-book
-
Notifications
You must be signed in to change notification settings - Fork 0
/
array_object.go
49 lines (47 loc) · 1.11 KB
/
array_object.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package heap
func (self *Object) Bytes() []int8 {
return self.data.([]int8)
}
func (self *Object) Shorts() []int16 {
return self.data.([]int16)
}
func (self *Object) Ints() []int32 {
return self.data.([]int32)
}
func (self *Object) Longs() []int64 {
return self.data.([]int64)
}
func (self *Object) Chars() []uint16 {
return self.data.([]uint16)
}
func (self *Object) Floats() []float32 {
return self.data.([]float32)
}
func (self *Object) Doubles() []float64 {
return self.data.([]float64)
}
func (self *Object) Refs() []*Object {
return self.data.([]*Object)
}
func (self *Object) ArrayLength() int32 {
switch self.data.(type) {
case []int8:
return int32(len(self.data.([]int8)))
case []int16:
return int32(len(self.data.([]int16)))
case []int32:
return int32(len(self.data.([]int32)))
case []int64:
return int32(len(self.data.([]int64)))
case []uint16:
return int32(len(self.data.([]uint16)))
case []float32:
return int32(len(self.data.([]float32)))
case []float64:
return int32(len(self.data.([]float64)))
case []*Object:
return int32(len(self.data.([]*Object)))
default:
panic("Not array!")
}
}