<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                ~~~ /* Observer 觀察者模式: 定義了一種一對多的依賴關系,讓多個觀察者對象同時監聽某一個主題對象。 這個主題對象在狀態發生改變時,會通知所有觀察者對象,使它們能夠自動更新自己。 個人想法:抽象通知者依賴抽象觀察者,具體觀察者依賴具體通知者 作者: HCLAC 日期: 20170310 */ package observer import ( "fmt" ) type Subject interface { Notify() State() int SetState(int) AddCallFunc(*update) RemoveCallFunc(*update) } type update func(int) type SubjectA struct { state int call []*update } func (s *SubjectA) Notify() { if s == nil { return } for _, c := range s.call { (*c)(s.state) } } func (s *SubjectA) State() int { if s == nil { return 0 } return s.state } func (s *SubjectA) SetState(i int) { if s == nil { return } s.state = i } func (s *SubjectA) AddCallFunc(f *update) { if s == nil { return } for _, c := range s.call { if c == f { return } } s.call = append(s.call, f) } func (s *SubjectA) RemoveCallFunc(f *update) { if s == nil { return } for i, c := range s.call { if c == f { s.call = append(s.call[:i], s.call[i+1:]...) } } } func NewSubjectA(s int) *SubjectA { return &SubjectA{s, []*update{}} } type Observer interface { Update(int) } type ObserverA struct { s Subject state int } func (o *ObserverA) Update(s int) { if o == nil { return } fmt.Println("ObserverA") fmt.Println(s) fmt.Println(o) } func NewObserverA(sa Subject, s int) *ObserverA { return &ObserverA{sa, s} } type ObserverB struct { s Subject state int } func (o *ObserverB) Update(s int) { if o == nil { return } fmt.Println("ObserverB") fmt.Println(s) fmt.Println(o) } func NewObserverB(sa Subject, s int) *ObserverB { return &ObserverB{sa, s} } ~~~
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看