亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? pat5f.htm

?? java設(shè)計范式.rar
?? HTM
?? 第 1 頁 / 共 2 頁
字號:
</OL><A NAME="implementation"></A><H2><A HREF="#samplecode"><IMG SRC="gifsb/down3.gif" BORDER=0 ALT="next: Sample Code"></A> Implementation</H2> <A NAME="auto1048"></A><P>Here are two issues to consider when implementing the Memento pattern:</P><OL><A NAME="auto1049"></A><LI><EM>Language support.</EM>Mementos have two interfaces: a wide one for originators and a narrowone for other objects.  Ideally the implementation language willsupport two levels of static protection.  C++ lets you do this bymaking the Originator a friend of Memento and making Memento's wideinterface private.  Only the narrow interface should be declaredpublic.  For example:<A NAME="auto1050"></A><PRE>    class State;        class Originator {    public:        Memento* CreateMemento();        void SetMemento(const Memento*);        // ...    private:        State* _state;      // internal data structures        // ...    };        class Memento {    public:        // narrow public interface        virtual ~Memento();    private:        // private members accessible only to Originator        friend class Originator;        Memento();            void SetState(State*);        State* GetState();        // ...    private:        State* _state;        // ...    };</PRE></LI><A NAME="state-incr-changes"></A><LI><EM>Storing incremental changes.</EM>When mementos get created and passed back to their originator in apredictable sequence, then Memento can save just the <EM>incrementalchange</EM> to the originator's internal state.<A NAME="undoable"></A><P>For example, undoable commands in a history list can use mementos toensure that commands are restored to their exact state when they'reundone (see <A HREF="pat5bfs.htm" TARGET="_mainDisplayFrame">Command (233)</A>).  The history list defines aspecific order in which commands can be undone and redone.  That meansmementos can store just the incremental change that a command makesrather than the full state of every object they affect.  In theMotivation example given earlier, the constraint solver can store only thoseinternal structures that change to keep the line connecting therectangles, as opposed to storing the absolute positions of theseobjects.</P></LI></OL><A NAME="samplecode"><A><H2><A HREF="#knownuses"><IMG SRC="gifsb/down3.gif" BORDER=0 ALT="next: Known Uses"></A> Sample Code</H2> <A NAME="auto1051"></A><P>The C++ code given here illustrates the ConstraintSolver example discussed earlier.  Weuse MoveCommand objects (see <A HREF="pat5bfs.htm" TARGET="_mainDisplayFrame">Command (233)</A>) to (un)dothe translation of a graphical object from one position to another.The graphical editor calls the command's <CODE>Execute</CODE> operationto move a graphical object and <CODE>Unexecute</CODE> to undo the move.The command stores its target, the distance moved, and an instance of<CODE>ConstraintSolverMemento</CODE>, a memento containing state from theconstraint solver.</P><A NAME="auto1052"></A><PRE>    class Graphic;        // base class for graphical objects in the graphical editor        class MoveCommand {    public:        MoveCommand(Graphic* target, const Point&amp; delta);        void Execute();        void Unexecute();    private:        ConstraintSolverMemento* _state;        Point _delta;        Graphic* _target;    };</PRE><A NAME="auto1053"></A><P>The connection constraints are established by the class<CODE>ConstraintSolver</CODE>. Its key member function is<CODE>Solve</CODE>, which solves the constraints registered withthe <CODE>AddConstraint</CODE> operation. To support undo,<CODE>ConstraintSolver</CODE>'s state can be externalized with<CODE>CreateMemento</CODE> into a <CODE>ConstraintSolverMemento</CODE>instance.  The constraint solver can be returned to a previousstate by calling <CODE>SetMemento</CODE>.  <CODE>ConstraintSolver</CODE>is a <A HREF="pat3efs.htm" TARGET="_mainDisplayFrame">Singleton (127)</A>.</P><A NAME="auto1054"></A><PRE>    class ConstraintSolver {    public:        static ConstraintSolver* Instance();            void Solve();        void AddConstraint(            Graphic* startConnection, Graphic* endConnection        );        void RemoveConstraint(            Graphic* startConnection, Graphic* endConnection        );            ConstraintSolverMemento* CreateMemento();        void SetMemento(ConstraintSolverMemento*);    private:        // nontrivial state and operations for enforcing        // connectivity semantics    };        class ConstraintSolverMemento {    public:        virtual ~ConstraintSolverMemento();    private:        friend class ConstraintSolver;        ConstraintSolverMemento();            // private constraint solver state    };</PRE><A NAME="auto1055"></A><P><A NAME="auto1056"></A><P>Given these interfaces, we can implement <CODE>MoveCommand</CODE> members<CODE>Execute</CODE> and <CODE>Unexecute</CODE> as follows:</P><A NAME="auto1057"></A><PRE>    void MoveCommand::Execute () {        ConstraintSolver* solver = ConstraintSolver::Instance();        _state = solver->CreateMemento(); // create a memento        _target->Move(_delta);        solver->Solve();    }        void MoveCommand::Unexecute () {        ConstraintSolver* solver = ConstraintSolver::Instance();        _target->Move(-_delta);        solver->SetMemento(_state); // restore solver state        solver->Solve();    }</PRE><A NAME="auto1058"></A><P><CODE>Execute</CODE> acquires a <CODE>ConstraintSolverMemento</CODE> mementobefore it moves the graphic. <CODE>Unexecute</CODE> moves the graphicback, sets the constraint solver's state to the previous state, andfinally tells the constraint solver to solve the constraints.</P><A NAME="knownuses"><A><H2><A HREF="#relatedpatterns"><IMG SRC="gifsb/down3.gif" BORDER=0 ALT="next: Related Patterns"></A> Known Uses</H2> <A NAME="unidraw-use-meme"></A><P>The preceding sample code is based on Unidraw's support for connectivitythrough its CSolver class [<A HREF="bibfs.htm#unidraw_framework" TARGET="_mainDisplayFrame">VL90</A>].</P><A NAME="auto1059"></A><P>Collections in Dylan [<A HREF="bibfs.htm#Dylan" TARGET="_mainDisplayFrame">App92</A>] provide an iteration interface thatreflects the Memento pattern. Dylan's collections have the notion of a"state" object, which is a memento that represents the state of theiteration. Each collection can represent the current state of theiteration in any way it chooses; the representation is completelyhidden from clients. The Dylan iteration approach might be translatedto C++ as follows:</P><A NAME="auto1060"></A><PRE>    template &lt;class Item>    class Collection {    public:        Collection();            IterationState* CreateInitialState();        void Next(IterationState*);        bool IsDone(const IterationState*) const;        Item CurrentItem(const IterationState*) const;        IterationState* Copy(const IterationState*) const;            void Append(const Item&amp;);        void Remove(const Item&amp;);        // ...    };</PRE><A NAME="auto1061"></A><P><CODE>CreateInitialState</CODE> returns an initialized<CODE>IterationState</CODE> object for the collection. <CODE>Next</CODE> advancesthe state object to the next position in the iteration; it effectivelyincrements the iteration index.  <CODE>IsDone</CODE> returns<CODE>true</CODE> if <CODE>Next</CODE> has advanced beyond the last elementin the collection. <CODE>CurrentItem</CODE> dereferences the stateobject and returns the element in the collection to which it refers.<CODE>Copy</CODE> returns a copy of the given state object.  This isuseful for marking a point in an iteration.</P><A NAME="auto1062"></A><P>Given a class <CODE>ItemType</CODE>, we can iterate over a collection ofits instances as follows<A NAME="fn7"></A><SUP><A HREF="#footnote7">7</A></SUP>:</P><A NAME="auto1063"></A><PRE>    class ItemType {    public:        void Process();        // ...    };        Collection&lt;ItemType*> aCollection;    IterationState* state;        state = aCollection.CreateInitialState();        while (!aCollection.IsDone(state)) {        aCollection.CurrentItem(state)->Process();        aCollection.Next(state);    }    delete state;</PRE><A NAME="auto1064"></A><P>The memento-based iteration interface has two interesting benefits:</P><OL><A NAME="auto1065"></A><LI>More than one state can work on the same collection.  (The sameis true of the <A HREF="pat5dfs.htm" TARGET="_mainDisplayFrame">Iterator (257)</A> pattern.)</LI><A NAME="auto1066"></A><P></P><A NAME="auto1067"></A><LI>It doesn't require breaking a collection's encapsulationto support iteration.  The memento is only interpreted by thecollection itself; no one else has access to it.  Other approaches toiteration require breaking encapsulation by making iterator classesfriends of their collection classes (see<A HREF="pat5dfs.htm" TARGET="_mainDisplayFrame">Iterator (257)</A>). The situation is reversed in thememento-based implementation: <CODE>Collection</CODE> is a friend of the<CODE>IteratorState</CODE>.</LI></OL><A NAME="qoca-use-memento"></A><P>The QOCA constraint-solving toolkit stores incremental information inmementos [<A HREF="bibfs.htm#qoca" TARGET="_mainDisplayFrame">HHMV92</A>].  Clients can obtain a memento that characterizesthe current solution to a system of constraints.  The memento containsonly those constraint variables that have changed since the lastsolution.  Usually only a small subset of the solver's variableschanges for each new solution.  This subset is enough to return thesolver to the preceding solution; reverting to earlier solutionsrequires restoring mementos from the intervening solutions.  Hence youcan't set mementos in any order; QOCA relies on a history mechanism torevert to earlier solutions.</P><A NAME="relatedpatterns"></A><H2><A HREF="#last"><IMG SRC="gifsb/down3.gif" BORDER=0 ALT="next: navigation"></A> Related Patterns</H2> <A NAME="auto1068"></A><P><A HREF="pat5bfs.htm" TARGET="_mainDisplayFrame">Command (233)</A>: Commands can use mementos to maintainstate for undoable operations.</P><A NAME="auto1069"></A><P><A HREF="pat5dfs.htm" TARGET="_mainDisplayFrame">Iterator (257)</A>: Mementoscan be used for iteration as described earlier.</P><A NAME="last"></A><P><A HREF="#intent"><IMG SRC="gifsb/up3.gif" BORDER=0></A><BR><A HREF="pat5gfs.htm" TARGET="_mainDisplayFrame"><IMG SRC="gifsb/rightar3.gif"        ALIGN=TOP BORDER=0></A> <A HREF="pat5gfs.htm"        TARGET="_mainDisplayFrame">Observer</A><BR><A HREF="pat5efs.htm" TARGET="_mainDisplayFrame"><IMG SRC="gifsb/leftarr3.gif"        ALIGN=TOP BORDER=0></A> <A HREF="pat5efs.htm"        TARGET="_mainDisplayFrame">Mediator</A></P><HR><A NAME="footnote7"></A><SUP>7</SUP>Note that our example deletes thestate object at the end of the iteration.  But <CODE>delete</CODE> won'tget called if <CODE>ProcessItem</CODE> throws an exception, thus creatinggarbage.  This is a problem in C++ but not in Dylan, which has garbagecollection.  We discuss a solution to this problem on<A HREF="pat5dfs.htm#clean-up_proxy_for_iterators" TARGET="_mainDisplayFrame">page 266</A>.</P></BODY></HTML>

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲免费毛片网站| 日韩精品专区在线影院重磅| 中文字幕高清不卡| 成人精品视频.| 日韩理论电影院| 欧美午夜在线观看| 午夜久久久久久电影| 日韩欧美国产成人一区二区| 久久99国产精品尤物| 国产欧美一区二区三区鸳鸯浴| 成人精品国产免费网站| 一个色在线综合| 日韩欧美的一区| 懂色av中文字幕一区二区三区 | 免费成人av资源网| 精品美女在线播放| 91香蕉视频mp4| 午夜视频一区在线观看| 亚洲精品一线二线三线无人区| 国产东北露脸精品视频| 亚洲综合图片区| 亚洲精品在线观看网站| 91浏览器入口在线观看| 麻豆成人免费电影| 亚洲欧洲精品一区二区三区 | 欧美一区二区三区成人| 国产91丝袜在线18| 亚洲电影第三页| 国产亚洲精品福利| 欧美日本国产一区| 成人av中文字幕| 热久久久久久久| 自拍视频在线观看一区二区| 日韩午夜在线播放| 国产精品91xxx| 国产精品网站导航| 日韩欧美国产成人一区二区| 91麻豆福利精品推荐| 国内成人精品2018免费看| 亚洲一区二区在线免费看| 国产欧美中文在线| 日韩一区二区在线看| 99久久99久久久精品齐齐| 韩国女主播一区| 丝袜诱惑制服诱惑色一区在线观看| 中文字幕第一区二区| 精品少妇一区二区三区免费观看| 色av一区二区| 成人午夜激情在线| 韩国精品免费视频| 日本成人中文字幕| 亚洲成精国产精品女| 最好看的中文字幕久久| 国产午夜亚洲精品不卡| 日韩女优av电影| 欧美另类变人与禽xxxxx| 色久优优欧美色久优优| 99精品视频一区二区三区| 国产成人av电影| 国产一区二区精品久久91| 久久不见久久见免费视频7| 亚洲18影院在线观看| 夜色激情一区二区| 亚洲男同性恋视频| 亚洲视频免费看| 一区二区中文字幕在线| 1024成人网色www| 国产精品成人免费在线| 中文字幕亚洲一区二区av在线 | 国v精品久久久网| 国产呦精品一区二区三区网站| 美脚の诱脚舐め脚责91 | 成人一区二区三区视频 | 成人高清免费在线播放| 国产成人精品免费视频网站| 国产黄色精品视频| 成人精品视频网站| 99精品在线免费| 91福利精品视频| 欧美日韩一二三区| 91精品婷婷国产综合久久性色| 制服丝袜日韩国产| 欧美一卡二卡三卡四卡| 精品国产乱码久久久久久1区2区 | 欧美日韩国产高清一区| 欧美三级视频在线观看| 欧美精品777| 欧美r级电影在线观看| 国产人妖乱国产精品人妖| 狠狠久久亚洲欧美| 午夜久久久久久| 青青草国产精品97视觉盛宴| 久久不见久久见免费视频1| 国产中文一区二区三区| 成人禁用看黄a在线| 色婷婷香蕉在线一区二区| 欧美日本一区二区三区四区| 欧美成人精品二区三区99精品| 久久男人中文字幕资源站| 日本视频一区二区三区| 精品国产91亚洲一区二区三区婷婷| 精品国产网站在线观看| 国产女主播一区| 亚洲精品乱码久久久久久黑人| 亚洲一区二区四区蜜桃| 精品一区二区三区久久久| 成人精品小蝌蚪| 欧美精品久久久久久久久老牛影院| 欧美成va人片在线观看| 亚洲日本成人在线观看| 日韩国产在线观看一区| 成人一二三区视频| 精品视频在线免费看| 国产亚洲欧美日韩俺去了| 一级精品视频在线观看宜春院 | 国产精品美女久久久久久2018| 亚洲黄色片在线观看| 激情久久五月天| 日本道色综合久久| 久久午夜电影网| 亚洲va欧美va天堂v国产综合| 国产一区欧美二区| 色av成人天堂桃色av| ww亚洲ww在线观看国产| 亚洲国产综合色| 国产精品一区久久久久| 欧美日韩激情一区二区三区| 国产精品无遮挡| 青娱乐精品在线视频| 精品一区二区三区免费毛片爱| 91麻豆.com| 久久九九久久九九| 日韩黄色免费网站| 色综合久久久久久久久久久| 欧洲av一区二区嗯嗯嗯啊| 日韩精品五月天| 色综合久久中文字幕| 国产人成亚洲第一网站在线播放| 肉肉av福利一精品导航| 91美女片黄在线| 中文字幕不卡在线观看| 激情国产一区二区| 91精品国产手机| 性久久久久久久| 在线一区二区三区做爰视频网站| 国产欧美日韩在线看| 久久国产精品72免费观看| 欧美丰满高潮xxxx喷水动漫| 亚洲精品ww久久久久久p站| 高清av一区二区| 久久久久久久av麻豆果冻| 看片的网站亚洲| 91麻豆精品国产91久久久久久久久 | 日韩欧美在线观看一区二区三区| 亚洲激情在线激情| 99精品视频免费在线观看| 欧美激情自拍偷拍| 国产精品一品二品| 久久九九全国免费| 国产高清一区日本| 久久久久久久久蜜桃| 精东粉嫩av免费一区二区三区| 欧美白人最猛性xxxxx69交| 日本不卡高清视频| 日韩欧美中文一区| 韩国v欧美v日本v亚洲v| 精品久久久久一区| 国内精品免费**视频| 久久综合久久鬼色中文字| 韩国女主播一区二区三区| 亚洲精品一区二区三区香蕉| 精品一区二区日韩| 久久久久久9999| av在线播放一区二区三区| 亚洲婷婷在线视频| 日本精品一级二级| 亚洲福利视频一区| 欧美一三区三区四区免费在线看 | 欧美午夜电影网| 天天综合网天天综合色| 91精品国产欧美一区二区成人| 水野朝阳av一区二区三区| 欧美一区二区视频观看视频| 精品制服美女久久| 欧美经典三级视频一区二区三区| 99视频精品全部免费在线| 亚洲欧美视频一区| 6080午夜不卡| 国产成人免费在线| 亚洲免费av在线| 欧美一区二区三区在线视频| 91香蕉视频在线| 亚洲成av人片一区二区三区| 欧美一区二区在线播放| 国产一区二区在线看| 成人免费在线视频| 欧美片网站yy| 国产一区二区不卡在线 | 亚洲欧美影音先锋| 欧美日韩一区二区三区四区|