MCPcopy Create free account
hub / github.com/betty200744/ultimate-go / Max

Method Max

algorithms/data-structures/stack/stack.go:48–68  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

46 return el
47}
48func (s *Stack) Max() interface{} {
49 if s.IsEmpty() {
50 return 0
51 }
52 max := s.stack[0]
53 for i := 0; i < s.len; i++ {
54 switch v := reflect.ValueOf(s.stack[i]); v.Kind() {
55 case reflect.String:
56 if s.stack[i].(string) > max.(string) {
57 max = s.stack[i]
58 }
59 case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
60 if s.stack[i].(int) > max.(int) {
61 max = s.stack[i]
62 }
63 default:
64 max = 0
65 }
66 }
67 return max
68}

Callers 4

mainFunction · 0.80
HeightFunction · 0.80
TestStack_MaxFunction · 0.80
inRangeFunction · 0.80

Calls 1

IsEmptyMethod · 0.95

Tested by 1

TestStack_MaxFunction · 0.64