MCPcopy
hub / github.com/lxn/walk / Insert

Method Insert

widgetlist.go:101–123  ·  view source on GitHub ↗
(index int, item Widget)

Source from the content-addressed store, hash-verified

99}
100
101func (l *WidgetList) Insert(index int, item Widget) error {
102 if l.Contains(item) {
103 return newError("cannot insert same widget multiple times")
104 }
105
106 observer := l.observer
107 if observer != nil {
108 if err := observer.onInsertingWidget(index, item); err != nil {
109 return err
110 }
111 }
112
113 l.insertIntoSlice(index, item)
114
115 if observer != nil {
116 if err := observer.onInsertedWidget(index, item); err != nil {
117 l.items = append(l.items[:index], l.items[index+1:]...)
118 return err
119 }
120 }
121
122 return nil
123}
124
125func (l *WidgetList) Len() int {
126 return len(l.items)

Callers 2

AddMethod · 0.95
onInsertedWidgetMethod · 0.45

Calls 5

ContainsMethod · 0.95
insertIntoSliceMethod · 0.95
newErrorFunction · 0.85
onInsertingWidgetMethod · 0.65
onInsertedWidgetMethod · 0.65

Tested by

no test coverage detected