diff options
Diffstat (limited to 'doc/latex/classmeow_1_1Self.tex')
-rw-r--r-- | doc/latex/classmeow_1_1Self.tex | 160 |
1 files changed, 117 insertions, 43 deletions
diff --git a/doc/latex/classmeow_1_1Self.tex b/doc/latex/classmeow_1_1Self.tex index 8ac76bc..5b60f6c 100644 --- a/doc/latex/classmeow_1_1Self.tex +++ b/doc/latex/classmeow_1_1Self.tex @@ -10,13 +10,24 @@ {\ttfamily \#include \char`\"{}Self.\-h\char`\"{}} +\subsection*{Public Types} +\begin{DoxyCompactItemize} +\item +enum \hyperlink{classmeow_1_1Self_aa7d169e9d20d590f3e571206084797f8}{Duplicate\-Type} \{ \hyperlink{classmeow_1_1Self_aa7d169e9d20d590f3e571206084797f8adef1b0d02e1090b1b610a4ea91bd6730}{C\-O\-P\-Y\-\_\-\-F\-R\-O\-M}, +\hyperlink{classmeow_1_1Self_aa7d169e9d20d590f3e571206084797f8a40c8a3eba568e04a5ce09ee0fa881822}{R\-E\-F\-E\-R\-E\-N\-C\-E\-\_\-\-F\-R\-O\-M} + \} +\begin{DoxyCompactList}\small\item\em 複製資料的方法 \end{DoxyCompactList}\end{DoxyCompactItemize} \subsection*{Public Member Functions} \begin{DoxyCompactItemize} \item -\hyperlink{classmeow_1_1Self_a0db7c98f250aeee3b06a49ebe0f16937}{Self} (bool create\-\_\-body) -\begin{DoxyCompactList}\small\item\em constructor \end{DoxyCompactList}\item +\hyperlink{classmeow_1_1Self_a6b39fcc4b184809f9aeaeb1c9a0bac2d}{Self} () +\begin{DoxyCompactList}\small\item\em constructor, 並宣告一個實體 \end{DoxyCompactList}\item +\hyperlink{classmeow_1_1Self_af3220c1e1d7966c6dbaf4ec62f8cbc2f}{Self} (Data const \&d) +\begin{DoxyCompactList}\small\item\em connstructor, 宣告一個實體, 其中該實體的constructor用copy constructor \end{DoxyCompactList}\item +\hyperlink{classmeow_1_1Self_af98a65e83bb96c0860d91a5013b269ef}{Self} (\hyperlink{classmeow_1_1Self}{Self} const \&b, \hyperlink{classmeow_1_1Self_aa7d169e9d20d590f3e571206084797f8}{Duplicate\-Type} d=\hyperlink{classmeow_1_1Self_aa7d169e9d20d590f3e571206084797f8adef1b0d02e1090b1b610a4ea91bd6730}{C\-O\-P\-Y\-\_\-\-F\-R\-O\-M}) +\begin{DoxyCompactList}\small\item\em constructor, 使用給定的\-Self當作init value, 並且可以指定要用 reference還是copy \end{DoxyCompactList}\item \hyperlink{classmeow_1_1Self_a000ede7e217c31401cc0a4b1c6749ee5}{Self} (\hyperlink{classmeow_1_1Self}{Self} const \&b) -\begin{DoxyCompactList}\small\item\em 不允許copy constructor \end{DoxyCompactList}\item +\begin{DoxyCompactList}\small\item\em Disallow copy constructor. \end{DoxyCompactList}\item \hyperlink{classmeow_1_1Self_ada16564a03665b10810a6342d61044bc}{$\sim$\-Self} () \begin{DoxyCompactList}\small\item\em 解構子 \end{DoxyCompactList}\item Data const $\ast$ \hyperlink{classmeow_1_1Self_a6063551c3e6ac647500e938ade8fbc99}{operator-\/$>$} () const @@ -25,10 +36,12 @@ Data $\ast$ \hyperlink{classmeow_1_1Self_ace312355261c68ac7531767939f5c4c2}{oper \begin{DoxyCompactList}\small\item\em 回傳指向 Data 的指標, 如有需要, 這邊會做資料的duplicate \end{DoxyCompactList}\item \hyperlink{classmeow_1_1Self}{Self} \& \hyperlink{classmeow_1_1Self_a5962339e9ee49312ab770f1119256ca6}{operator()} () const \begin{DoxyCompactList}\small\item\em 回傳非const型態的自己 \end{DoxyCompactList}\item -void \hyperlink{classmeow_1_1Self_a7ae7da730705bf2330a259308e5a6828}{copy\-From} (\hyperlink{classmeow_1_1Self}{Self} const \&s) +\hyperlink{classmeow_1_1Self}{Self} const \& \hyperlink{classmeow_1_1Self_a9cd016a38a09f479fe2ed83eb1ebdae2}{copy\-From} (\hyperlink{classmeow_1_1Self}{Self} const \&s) \begin{DoxyCompactList}\small\item\em 將給定的 {\ttfamily \hyperlink{classmeow_1_1Self}{Self}} 的資料複製到自己這裡 \end{DoxyCompactList}\item -void \hyperlink{classmeow_1_1Self_a576e99ba0ba6e8263b4d2cfd9238440f}{reference\-From} (\hyperlink{classmeow_1_1Self}{Self} const \&s) +\hyperlink{classmeow_1_1Self}{Self} const \& \hyperlink{classmeow_1_1Self_a63e1570c927c7fa3b95b71fe978e355d}{reference\-From} (\hyperlink{classmeow_1_1Self}{Self} const \&s) \begin{DoxyCompactList}\small\item\em 將自己reference 到給定的 {\ttfamily \hyperlink{classmeow_1_1Self}{Self}} \end{DoxyCompactList}\item +\hyperlink{classmeow_1_1Self}{Self} const \& \hyperlink{classmeow_1_1Self_ae4256bfc598bb0db76141ffce506806e}{duplicate\-From} (\hyperlink{classmeow_1_1Self}{Self} const \&s, \hyperlink{classmeow_1_1Self_aa7d169e9d20d590f3e571206084797f8}{Duplicate\-Type} t) +\begin{DoxyCompactList}\small\item\em 依據給定\-Duplicate\-Type選擇要呼叫copy\-From還是reference\-From \end{DoxyCompactList}\item bool \hyperlink{classmeow_1_1Self_ab3671e44693b79e2f987f59652d46ca9}{same} (\hyperlink{classmeow_1_1Self}{Self} const \&s) const \begin{DoxyCompactList}\small\item\em 比對兩個 {\ttfamily \hyperlink{classmeow_1_1Self}{Self}} 是否指向同一個reference \end{DoxyCompactList}\item bool \hyperlink{classmeow_1_1Self_a91098e2218c358470e81d64f35d6491d}{equal} (\hyperlink{classmeow_1_1Self}{Self} const \&s) const @@ -51,48 +64,38 @@ void \hyperlink{classmeow_1_1Self_af3277e1109c59e5f81549889b344a675}{operator=} \textcolor{keyword}{private}: \textcolor{keyword}{struct }Myself \{ \textcolor{keywordtype}{int} data; - Myself()\{ + Myself() \{ \textcolor{comment}{// 必要} data = 0; \} + Myself(Myself \textcolor{keyword}{const}& b): data(b.data) \{ \textcolor{comment}{// 必要, copy constructor} + \} ~Myself() \{ \} - Myself \hyperlink{classmeow_1_1Self_a7ae7da730705bf2330a259308e5a6828}{copyFrom}(Myself \textcolor{keyword}{const}& ms)\textcolor{keyword}{ const }\{ - data = ms.data; + \textcolor{keywordtype}{bool} operator==(Myself \textcolor{keyword}{const}& b)\textcolor{keyword}{ const }\{ \textcolor{comment}{// 不一定需要(有用到equal()才要)} + \textcolor{keywordflow}{return} (data == b.data); \} \}; + Self<Myself> \textcolor{keyword}{const} \textcolor{keyword}{self}; \textcolor{keyword}{public}: - A(): self(true) \{ \textcolor{comment}{// self(true) 表示要建立實體, 即struct Myself} - \} - A(A \textcolor{keyword}{const}& a): self(false) \{ \textcolor{comment}{// for std::swap} - \hyperlink{classmeow_1_1Self_a7ae7da730705bf2330a259308e5a6828}{copyFrom}(a); - \} - \textcolor{comment}{// A(A const& a); // disable 模糊用法, 與上者二選一} - A(A \textcolor{keyword}{const}& a, \textcolor{keywordtype}{bool} reference): self(false) \{ - \textcolor{keywordflow}{if} (reference) \{ - \hyperlink{classmeow_1_1Self_a576e99ba0ba6e8263b4d2cfd9238440f}{referenceFrom}(a); - \} \textcolor{keywordflow}{else} \{ - \hyperlink{classmeow_1_1Self_a7ae7da730705bf2330a259308e5a6828}{copyFrom}(a); - \} - \} - ~A() \{ - \} + A(): self() \{ \} \textcolor{comment}{// 預設呼叫Myself()} + A(A \textcolor{keyword}{const}& a): self(a.self, \hyperlink{classmeow_1_1Self_aa7d169e9d20d590f3e571206084797f8adef1b0d02e1090b1b610a4ea91bd6730}{COPY\_FROM}) \{ \} \textcolor{comment}{// 用Myself(b)做到copyFrom} + ~A() \{ \} \textcolor{keywordtype}{void} setMemeber(\textcolor{keywordtype}{int} k) \{ \textcolor{keyword}{self}()->data = k; \textcolor{comment}{// self()->?? 可以有write權限} \} \textcolor{keywordtype}{int} getMemember(\textcolor{keywordtype}{int} wh)\textcolor{keyword}{ const }\{ \textcolor{keywordflow}{return} \textcolor{keyword}{self}->data; \textcolor{comment}{// self->?? 只有const} \} - A \hyperlink{classmeow_1_1Self_a576e99ba0ba6e8263b4d2cfd9238440f}{referenceFrom}(A \textcolor{keyword}{const}& a) \{ - \textcolor{keyword}{self}.referenceFrom(a.self); + A \hyperlink{classmeow_1_1Self_a63e1570c927c7fa3b95b71fe978e355d}{referenceFrom}(A \textcolor{keyword}{const}& a) \{ + \textcolor{keyword}{self}.\hyperlink{classmeow_1_1Self_a63e1570c927c7fa3b95b71fe978e355d}{referenceFrom}(a.self); \} - A \hyperlink{classmeow_1_1Self_a7ae7da730705bf2330a259308e5a6828}{copyFrom}(A \textcolor{keyword}{const}& a) \{ - \textcolor{keyword}{self}.copyFrom(a.self); + A \hyperlink{classmeow_1_1Self_a9cd016a38a09f479fe2ed83eb1ebdae2}{copyFrom}(A \textcolor{keyword}{const}& a) \{ + \textcolor{keyword}{self}.\hyperlink{classmeow_1_1Self_a9cd016a38a09f479fe2ed83eb1ebdae2}{copyFrom}(a.self); \} A& \hyperlink{classmeow_1_1Self_af3277e1109c59e5f81549889b344a675}{operator=}(A \textcolor{keyword}{const}& b) \{ \textcolor{comment}{// for std::swap} - \hyperlink{classmeow_1_1Self_a7ae7da730705bf2330a259308e5a6828}{copyFrom}(b); + \hyperlink{classmeow_1_1Self_a9cd016a38a09f479fe2ed83eb1ebdae2}{copyFrom}(b); \} - A& \hyperlink{classmeow_1_1Self_af3277e1109c59e5f81549889b344a675}{operator=}(A \textcolor{keyword}{const}& b); \textcolor{comment}{// 避免諢亂用法} \}; \end{DoxyCode} @@ -105,21 +108,70 @@ cathook \end{DoxyWarning} +\subsection{Member Enumeration Documentation} +\hypertarget{classmeow_1_1Self_aa7d169e9d20d590f3e571206084797f8}{\index{meow\-::\-Self@{meow\-::\-Self}!Duplicate\-Type@{Duplicate\-Type}} +\index{Duplicate\-Type@{Duplicate\-Type}!meow::Self@{meow\-::\-Self}} +\subsubsection[{Duplicate\-Type}]{\setlength{\rightskip}{0pt plus 5cm}template$<$class Data$>$ enum {\bf meow\-::\-Self\-::\-Duplicate\-Type}}}\label{classmeow_1_1Self_aa7d169e9d20d590f3e571206084797f8} + + +複製資料的方法 + +\begin{Desc} +\item[Enumerator]\par +\begin{description} +\index{C\-O\-P\-Y\-\_\-\-F\-R\-O\-M@{C\-O\-P\-Y\-\_\-\-F\-R\-O\-M}!meow\-::\-Self@{meow\-::\-Self}}\index{meow\-::\-Self@{meow\-::\-Self}!C\-O\-P\-Y\-\_\-\-F\-R\-O\-M@{C\-O\-P\-Y\-\_\-\-F\-R\-O\-M}}\item[{\em +\hypertarget{classmeow_1_1Self_aa7d169e9d20d590f3e571206084797f8adef1b0d02e1090b1b610a4ea91bd6730}{C\-O\-P\-Y\-\_\-\-F\-R\-O\-M}\label{classmeow_1_1Self_aa7d169e9d20d590f3e571206084797f8adef1b0d02e1090b1b610a4ea91bd6730} +}]跟一般的複製一樣 \index{R\-E\-F\-E\-R\-E\-N\-C\-E\-\_\-\-F\-R\-O\-M@{R\-E\-F\-E\-R\-E\-N\-C\-E\-\_\-\-F\-R\-O\-M}!meow\-::\-Self@{meow\-::\-Self}}\index{meow\-::\-Self@{meow\-::\-Self}!R\-E\-F\-E\-R\-E\-N\-C\-E\-\_\-\-F\-R\-O\-M@{R\-E\-F\-E\-R\-E\-N\-C\-E\-\_\-\-F\-R\-O\-M}}\item[{\em +\hypertarget{classmeow_1_1Self_aa7d169e9d20d590f3e571206084797f8a40c8a3eba568e04a5ce09ee0fa881822}{R\-E\-F\-E\-R\-E\-N\-C\-E\-\_\-\-F\-R\-O\-M}\label{classmeow_1_1Self_aa7d169e9d20d590f3e571206084797f8a40c8a3eba568e04a5ce09ee0fa881822} +}]參照, 執行完兩個\-Self會完全等效 \end{description} +\end{Desc} + + \subsection{Constructor \& Destructor Documentation} -\hypertarget{classmeow_1_1Self_a0db7c98f250aeee3b06a49ebe0f16937}{\index{meow\-::\-Self@{meow\-::\-Self}!Self@{Self}} +\hypertarget{classmeow_1_1Self_a6b39fcc4b184809f9aeaeb1c9a0bac2d}{\index{meow\-::\-Self@{meow\-::\-Self}!Self@{Self}} +\index{Self@{Self}!meow::Self@{meow\-::\-Self}} +\subsubsection[{Self}]{\setlength{\rightskip}{0pt plus 5cm}template$<$class Data$>$ {\bf meow\-::\-Self}$<$ Data $>$\-::{\bf Self} ( +\begin{DoxyParamCaption} +{} +\end{DoxyParamCaption} +)\hspace{0.3cm}{\ttfamily [inline]}}}\label{classmeow_1_1Self_a6b39fcc4b184809f9aeaeb1c9a0bac2d} + + +constructor, 並宣告一個實體 + +\hypertarget{classmeow_1_1Self_af3220c1e1d7966c6dbaf4ec62f8cbc2f}{\index{meow\-::\-Self@{meow\-::\-Self}!Self@{Self}} +\index{Self@{Self}!meow::Self@{meow\-::\-Self}} +\subsubsection[{Self}]{\setlength{\rightskip}{0pt plus 5cm}template$<$class Data$>$ {\bf meow\-::\-Self}$<$ Data $>$\-::{\bf Self} ( +\begin{DoxyParamCaption} +\item[{Data const \&}]{d} +\end{DoxyParamCaption} +)\hspace{0.3cm}{\ttfamily [inline]}}}\label{classmeow_1_1Self_af3220c1e1d7966c6dbaf4ec62f8cbc2f} + + +connstructor, 宣告一個實體, 其中該實體的constructor用copy constructor + + +\begin{DoxyParams}[1]{Parameters} +\mbox{\tt in} & {\em d} & Inital data \\ +\hline +\end{DoxyParams} +\hypertarget{classmeow_1_1Self_af98a65e83bb96c0860d91a5013b269ef}{\index{meow\-::\-Self@{meow\-::\-Self}!Self@{Self}} \index{Self@{Self}!meow::Self@{meow\-::\-Self}} \subsubsection[{Self}]{\setlength{\rightskip}{0pt plus 5cm}template$<$class Data$>$ {\bf meow\-::\-Self}$<$ Data $>$\-::{\bf Self} ( \begin{DoxyParamCaption} -\item[{bool}]{create\-\_\-body} +\item[{{\bf Self}$<$ Data $>$ const \&}]{b, } +\item[{{\bf Duplicate\-Type}}]{d = {\ttfamily {\bf C\-O\-P\-Y\-\_\-\-F\-R\-O\-M}}} \end{DoxyParamCaption} -)\hspace{0.3cm}{\ttfamily [inline]}}}\label{classmeow_1_1Self_a0db7c98f250aeee3b06a49ebe0f16937} +)\hspace{0.3cm}{\ttfamily [inline]}}}\label{classmeow_1_1Self_af98a65e83bb96c0860d91a5013b269ef} -constructor +constructor, 使用給定的\-Self當作init value, 並且可以指定要用 reference還是copy \begin{DoxyParams}[1]{Parameters} -\mbox{\tt in} & {\em create\-\_\-body} & 是否要new一個實體資料 (如果constructor完, 馬上就要 {\ttfamily \hyperlink{classmeow_1_1Self_a7ae7da730705bf2330a259308e5a6828}{copy\-From()}} , 或是 {\ttfamily \hyperlink{classmeow_1_1Self_a576e99ba0ba6e8263b4d2cfd9238440f}{reference\-From()}} 的話 不太需要 new一個實體, 否則基本上都要 \\ +\mbox{\tt in} & {\em b} & 給定的\-Self \\ +\hline +\mbox{\tt in} & {\em d} & 指定要用copy還是reference \\ \hline \end{DoxyParams} \hypertarget{classmeow_1_1Self_a000ede7e217c31401cc0a4b1c6749ee5}{\index{meow\-::\-Self@{meow\-::\-Self}!Self@{Self}} @@ -131,7 +183,7 @@ constructor )}}\label{classmeow_1_1Self_a000ede7e217c31401cc0a4b1c6749ee5} -不允許copy constructor +Disallow copy constructor. \hypertarget{classmeow_1_1Self_ada16564a03665b10810a6342d61044bc}{\index{meow\-::\-Self@{meow\-::\-Self}!$\sim$\-Self@{$\sim$\-Self}} \index{$\sim$\-Self@{$\sim$\-Self}!meow::Self@{meow\-::\-Self}} @@ -147,13 +199,13 @@ constructor \subsection{Member Function Documentation} -\hypertarget{classmeow_1_1Self_a7ae7da730705bf2330a259308e5a6828}{\index{meow\-::\-Self@{meow\-::\-Self}!copy\-From@{copy\-From}} +\hypertarget{classmeow_1_1Self_a9cd016a38a09f479fe2ed83eb1ebdae2}{\index{meow\-::\-Self@{meow\-::\-Self}!copy\-From@{copy\-From}} \index{copy\-From@{copy\-From}!meow::Self@{meow\-::\-Self}} -\subsubsection[{copy\-From}]{\setlength{\rightskip}{0pt plus 5cm}template$<$class Data$>$ void {\bf meow\-::\-Self}$<$ Data $>$\-::copy\-From ( +\subsubsection[{copy\-From}]{\setlength{\rightskip}{0pt plus 5cm}template$<$class Data$>$ {\bf Self} const\& {\bf meow\-::\-Self}$<$ Data $>$\-::copy\-From ( \begin{DoxyParamCaption} \item[{{\bf Self}$<$ Data $>$ const \&}]{s} \end{DoxyParamCaption} -)\hspace{0.3cm}{\ttfamily [inline]}}}\label{classmeow_1_1Self_a7ae7da730705bf2330a259308e5a6828} +)\hspace{0.3cm}{\ttfamily [inline]}}}\label{classmeow_1_1Self_a9cd016a38a09f479fe2ed83eb1ebdae2} 將給定的 {\ttfamily \hyperlink{classmeow_1_1Self}{Self}} 的資料複製到自己這裡 @@ -164,11 +216,33 @@ constructor \hline \end{DoxyParams} \begin{DoxyReturn}{Returns} -無 +$\ast$this \end{DoxyReturn} \begin{DoxyNote}{Note} 與reference的差別是, copy之後若該給定的 {\ttfamily \hyperlink{classmeow_1_1Self}{Self}} 有資料修改, this 這邊 {\bfseries 不會} 被改到 \end{DoxyNote} +\hypertarget{classmeow_1_1Self_ae4256bfc598bb0db76141ffce506806e}{\index{meow\-::\-Self@{meow\-::\-Self}!duplicate\-From@{duplicate\-From}} +\index{duplicate\-From@{duplicate\-From}!meow::Self@{meow\-::\-Self}} +\subsubsection[{duplicate\-From}]{\setlength{\rightskip}{0pt plus 5cm}template$<$class Data$>$ {\bf Self} const\& {\bf meow\-::\-Self}$<$ Data $>$\-::duplicate\-From ( +\begin{DoxyParamCaption} +\item[{{\bf Self}$<$ Data $>$ const \&}]{s, } +\item[{{\bf Duplicate\-Type}}]{t} +\end{DoxyParamCaption} +)\hspace{0.3cm}{\ttfamily [inline]}}}\label{classmeow_1_1Self_ae4256bfc598bb0db76141ffce506806e} + + +依據給定\-Duplicate\-Type選擇要呼叫copy\-From還是reference\-From + + +\begin{DoxyParams}[1]{Parameters} +\mbox{\tt in} & {\em s} & 給定的 {\ttfamily \hyperlink{classmeow_1_1Self}{Self}} \\ +\hline +\mbox{\tt in} & {\em t} & 給定的 {\ttfamily Duplicate\-Type} \\ +\hline +\end{DoxyParams} +\begin{DoxyReturn}{Returns} +$\ast$this +\end{DoxyReturn} \hypertarget{classmeow_1_1Self_a91098e2218c358470e81d64f35d6491d}{\index{meow\-::\-Self@{meow\-::\-Self}!equal@{equal}} \index{equal@{equal}!meow::Self@{meow\-::\-Self}} \subsubsection[{equal}]{\setlength{\rightskip}{0pt plus 5cm}template$<$class Data$>$ bool {\bf meow\-::\-Self}$<$ Data $>$\-::equal ( @@ -235,13 +309,13 @@ constructor 將 {\ttfamily operator=} 給disable掉 -\hypertarget{classmeow_1_1Self_a576e99ba0ba6e8263b4d2cfd9238440f}{\index{meow\-::\-Self@{meow\-::\-Self}!reference\-From@{reference\-From}} +\hypertarget{classmeow_1_1Self_a63e1570c927c7fa3b95b71fe978e355d}{\index{meow\-::\-Self@{meow\-::\-Self}!reference\-From@{reference\-From}} \index{reference\-From@{reference\-From}!meow::Self@{meow\-::\-Self}} -\subsubsection[{reference\-From}]{\setlength{\rightskip}{0pt plus 5cm}template$<$class Data$>$ void {\bf meow\-::\-Self}$<$ Data $>$\-::reference\-From ( +\subsubsection[{reference\-From}]{\setlength{\rightskip}{0pt plus 5cm}template$<$class Data$>$ {\bf Self} const\& {\bf meow\-::\-Self}$<$ Data $>$\-::reference\-From ( \begin{DoxyParamCaption} \item[{{\bf Self}$<$ Data $>$ const \&}]{s} \end{DoxyParamCaption} -)\hspace{0.3cm}{\ttfamily [inline]}}}\label{classmeow_1_1Self_a576e99ba0ba6e8263b4d2cfd9238440f} +)\hspace{0.3cm}{\ttfamily [inline]}}}\label{classmeow_1_1Self_a63e1570c927c7fa3b95b71fe978e355d} 將自己reference 到給定的 {\ttfamily \hyperlink{classmeow_1_1Self}{Self}} @@ -252,7 +326,7 @@ constructor \hline \end{DoxyParams} \begin{DoxyReturn}{Returns} -無 +$\ast$this \end{DoxyReturn} \begin{DoxyNote}{Note} 把reference想像成指標會比較容易思考, 譬如 {\ttfamily a.\-reference\-From(b)} {\ttfamily b.\-reference\-From(c)} 相當於 {\bfseries a指向b原本指的記憶體位置}, {\bfseries b指向c原本指的記憶體位置} , 之後更動c時, 只有b會被牽連 |