()
| 46 | return el |
| 47 | } |
| 48 | func (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 | } |