📄 sharpictclas分词系统简介(3)dynamicarray - first we try, then we trust - 博客园.mht
字号:
=BB=E6=A0=B9=E6=8D=AErow=E4=BC=98=E5=85=88=E6=8E=92=E5=BA=8F=E8=BF=98=E6=98=
=AFcol=E4=BC=98=E5=85=88=E6=8E=92=E5=BA=8F=E8=87=AA=E8=A1=8C=E5=86=B3=E5=AE=
=9A=E5=85=B7=E4=BD=93=E5=AE=9E=E7=8E=B0=E3=80=82DynamicArray=E7=B1=BB=E7=9A=
=84=E4=BB=A3=E7=A0=81=E5=AE=9E=E7=8E=B0=E5=A6=82=E4=B8=8B=EF=BC=88=E5=BA=94=
=E5=BD=93=E8=AF=B4=E9=9D=9E=E5=B8=B8=E7=AE=80=E5=8D=95=EF=BC=89=EF=BC=9A<=
/P>
<DIV class=3Dcode>
<DIV class=3Dtitle>
<DIV style=3D"FLOAT: right"><IMG class=3DcopyCodeImage=20
src=3D"http://www.cnblogs.com/images/cnblogs_com/zhenyulu/200701/copycode=
.gif"=20
align=3DabsMiddle name=3DccImage> <A onclick=3DCopyCode(this) =
href=3D"javascript:">Copy=20
Code</A></DIV>
<DIV style=3D"CLEAR: none">DynamicArray.cs =
=E7=A8=8B=E5=BA=8F</DIV></DIV>
<DIV class=3Dcontent><SPAN style=3D"COLOR: #0000ff">public</SPAN> <SPAN=20
style=3D"COLOR: #0000ff">abstract</SPAN> <SPAN style=3D"COLOR: =
#0000ff">class</SPAN>=20
DynamicArray<T> <BR>{ <BR> <SPAN=20
style=3D"COLOR: #0000ff">protected</SPAN> ChainItem<T> =
pHead; <SPAN=20
style=3D"COLOR: #008000">//The head pointer of array chain =
</SPAN><BR> =20
<SPAN style=3D"COLOR: #0000ff">public</SPAN> <SPAN=20
style=3D"COLOR: #0000ff">int</SPAN> ColumnCount, RowCount; <SPAN=20
style=3D"COLOR: #008000">//The row and col of the array=20
</SPAN><BR><BR> <SPAN style=3D"COLOR: #0000ff">public</SPAN> =
DynamicArray() <BR> { <BR> =
pHead =3D=20
<SPAN style=3D"COLOR: #0000ff">null</SPAN>; =
<BR> =20
RowCount =3D 0; <BR> ColumnCount =3D 0;=20
<BR> } <BR><BR> <SPAN=20
style=3D"COLOR: #0000ff">public</SPAN> <SPAN style=3D"COLOR: =
#0000ff">int</SPAN>=20
ItemCount <BR> { <BR> <SPAN=20
style=3D"COLOR: #0000ff">get</SPAN> <BR> { =
<BR> ChainItem<T> =
pCur =3D=20
pHead; <BR> <SPAN=20
style=3D"COLOR: #0000ff">int</SPAN> nCount =3D 0;=20
<BR> <SPAN=20
style=3D"COLOR: #0000ff">while</SPAN> (pCur !=3D <SPAN=20
style=3D"COLOR: #0000ff">null</SPAN>)=20
<BR> {=20
<BR> =
nCount++;=20
<BR> =
pCur =3D=20
pCur.next; <BR> }=20
<BR> <SPAN=20
style=3D"COLOR: #0000ff">return</SPAN> nCount; =
<BR> =20
} <BR> } <BR><BR> <SPAN=20
style=3D"COLOR: =
#008000">//=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=20
</SPAN><BR> <SPAN style=3D"COLOR: #008000">// =
=E6=9F=A5=E6=89=BE=E8=A1=8C=E3=80=81=E5=88=97=E5=80=BC=E4=B8=BAnRow, =
nCol=E7=9A=84=E7=BB=93=E7=82=B9=20
</SPAN><BR> <SPAN=20
style=3D"COLOR: =
#008000">//=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=20
</SPAN><BR> <SPAN style=3D"COLOR: #0000ff">public</SPAN>=20
ChainItem<T> GetElement(<SPAN style=3D"COLOR: #0000ff">int</SPAN> =
nRow,=20
<SPAN style=3D"COLOR: #0000ff">int</SPAN> nCol) <BR> {=20
<BR> ChainItem<T> pCur =3D pHead;=20
<BR><BR> <SPAN style=3D"COLOR: =
#0000ff">while</SPAN>=20
(pCur !=3D <SPAN style=3D"COLOR: #0000ff">null</SPAN> && =
!(pCur.col =3D=3D nCol=20
&& pCur.row =3D=3D nRow))=20
<BR> pCur =3D pCur.next; =
<BR><BR> <SPAN=20
style=3D"COLOR: #0000ff">return</SPAN> pCur; <BR> }=20
<BR><BR> <SPAN=20
style=3D"COLOR: =
#008000">//=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=20
</SPAN><BR> <SPAN style=3D"COLOR: #008000">// =
=E8=AE=BE=E7=BD=AE=E6=88=96=E6=8F=92=E5=85=A5=E4=B8=80=E4=B8=AA=E6=96=B0=E7=
=9A=84=E7=BB=93=E7=82=B9=20
</SPAN><BR> <SPAN=20
style=3D"COLOR: =
#008000">//=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=20
</SPAN><BR> <SPAN style=3D"COLOR: #0000ff">public</SPAN> =
<SPAN=20
style=3D"COLOR: #0000ff">abstract</SPAN> <SPAN style=3D"COLOR: =
#0000ff">void</SPAN>=20
SetElement(<SPAN style=3D"COLOR: #0000ff">int</SPAN> nRow, <SPAN=20
style=3D"COLOR: #0000ff">int</SPAN> nCol, T content); =
<BR><BR> <SPAN=20
style=3D"COLOR: =
#008000">//=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=20
</SPAN><BR> <SPAN style=3D"COLOR: #008000">// Return the =
head element=20
of ArrayChain </SPAN><BR> <SPAN=20
style=3D"COLOR: =
#008000">//=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=20
</SPAN><BR> <SPAN style=3D"COLOR: #0000ff">public</SPAN>=20
ChainItem<T> GetHead() <BR> {=20
<BR> <SPAN style=3D"COLOR: =
#0000ff">return</SPAN>=20
pHead; <BR> } <BR><BR> <SPAN=20
style=3D"COLOR: =
#008000">//=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=20
</SPAN><BR> <SPAN style=3D"COLOR: #008000">//Get the tail =
Element=20
buffer and return the count of elements </SPAN><BR> <SPAN=20
style=3D"COLOR: =
#008000">//=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=20
</SPAN><BR> <SPAN style=3D"COLOR: #0000ff">public</SPAN> =
<SPAN=20
style=3D"COLOR: #0000ff">int</SPAN> GetTail(<SPAN=20
style=3D"COLOR: #0000ff">out</SPAN> ChainItem<T> pTailRet) =
<BR> =20
{ <BR> ChainItem<T> pCur =3D pHead, =
pPrev =3D=20
<SPAN style=3D"COLOR: #0000ff">null</SPAN>; =
<BR> =20
<SPAN style=3D"COLOR: #0000ff">int</SPAN> nCount =3D 0;=20
<BR> <SPAN style=3D"COLOR: =
#0000ff">while</SPAN>=20
(pCur !=3D <SPAN style=3D"COLOR: #0000ff">null</SPAN>)=20
<BR> {=20
<BR> nCount++;=20
<BR> pPrev =3D pCur;=20
<BR> pCur =3D pCur.next; =
<BR> } <BR> =
pTailRet=20
=3D pPrev; <BR> <SPAN=20
style=3D"COLOR: #0000ff">return</SPAN> nCount; <BR> }=20
<BR><BR> <SPAN=20
style=3D"COLOR: =
#008000">//=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=20
</SPAN><BR> <SPAN style=3D"COLOR: #008000">// Set Empty=20
</SPAN><BR> <SPAN=20
style=3D"COLOR: =
#008000">//=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=20
</SPAN><BR> <SPAN style=3D"COLOR: #0000ff">public</SPAN> =
<SPAN=20
style=3D"COLOR: #0000ff">void</SPAN> SetEmpty() <BR> {=20
<BR> pHead =3D <SPAN=20
style=3D"COLOR: #0000ff">null</SPAN>; <BR> =
ColumnCount =3D 0; <BR> RowCount =3D 0;=20
<BR> } <BR><BR> <SPAN=20
style=3D"COLOR: #0000ff">public</SPAN> <SPAN=20
style=3D"COLOR: #0000ff">override</SPAN> <SPAN=20
style=3D"COLOR: #0000ff">string</SPAN> ToString() <BR> {=20
<BR> StringBuilder sb =3D <SPAN=20
style=3D"COLOR: #0000ff">new</SPAN> StringBuilder();=20
<BR><BR> ChainItem<T> pCur =3D =
pHead;=20
<BR><BR> <SPAN style=3D"COLOR: =
#0000ff">while</SPAN>=20
(pCur !=3D <SPAN style=3D"COLOR: #0000ff">null</SPAN>)=20
<BR> {=20
<BR> sb.Append(<SPAN=20
style=3D"COLOR: #0000ff">string</SPAN>.Format(<SPAN=20
style=3D"COLOR: #ff00ff">"row:{0,3}, col:{1,3}, "</SPAN>, =
pCur.row,=20
pCur.col)); <BR> =20
sb.Append(pCur.Content.ToString());=20
<BR> sb.Append(<SPAN=20
style=3D"COLOR: #ff00ff">"\r\n"</SPAN>);=20
<BR> pCur =3D pCur.next; =
<BR> } =
<BR><BR> =20
<SPAN style=3D"COLOR: #0000ff">return</SPAN> sb.ToString(); =
<BR> }=20
<BR>}</DIV></DIV>
<H3>3=E3=80=81RowFirstDynamicArray=E7=B1=BB=E7=9A=84=E5=AE=9E=E7=8E=B0</H=
3>
<P>RowFirstDynamicArray=E7=B1=BB=E4=B8=BB=E8=A6=81=E5=AE=9E=E7=8E=B0=E4=BA=
=86row=E4=BC=98=E5=85=88=E6=8E=92=E5=BA=8F=E7=9A=84DynamicArray=EF=BC=8C=E9=
=87=8C=E9=9D=A2=E5=8C=85=E5=90=AB=E4=BA=86=E4=B8=A4=E4=B8=AA=E6=96=B9=E6=B3=
=95=EF=BC=9AGetFirstElementOfRow=EF=BC=88=E8=8E=B7=E5=8F=96row=E4=B8=BAnR=
ow=E7=9A=84=E7=AC=AC=E4=B8=80=E4=B8=AA=E5=85=83=E7=B4=A0=EF=BC=89=E5=92=8C=
SetElement=E6=96=B9=E6=B3=95=E3=80=82=E5=85=B6=E4=B8=ADGetFirstElementOfR=
ow=E6=9C=89=E4=B8=A4=E4=B8=AA=E9=87=8D=E8=BD=BD=E7=89=88=E6=9C=AC=E3=80=82=
</P>
<P>=E8=BF=99=E7=AD=89=E4=BB=B7=E4=BA=8E=E5=B0=86=E5=8E=9F=E6=9C=89ICTCLAS=
=E4=B8=ADGetElement=E6=96=B9=E6=B3=95=E6=8B=86=E5=88=86=E6=88=90=E4=BA=86=
=E4=B8=89=E4=B8=AA=E6=96=B9=E6=B3=95=EF=BC=8C=E5=A6=82=E6=9E=9C=E7=AE=97=E4=
=B8=8A=E9=87=8D=E8=BD=BD=E7=89=88=E6=9C=AC=E7=9A=84=E8=AF=9D=E5=85=B1=E4=BA=
=94=E4=B8=AA=E6=96=B9=E6=B3=95=EF=BC=8C=E5=AE=83=E4=BB=AC=E5=88=86=E5=88=AB=
=E6=98=AF=EF=BC=9A1=EF=BC=89=E8=8E=B7=E5=8F=96=E8=A1=8C=E3=80=81=E5=88=97=
=E5=80=BC=E4=B8=BAnRow,=20
nCol=E7=9A=84=E7=BB=93=E7=82=B9=EF=BC=8C=E6=AD=A4=E6=96=B9=E6=B3=95=E7=94=
=B1DynamicArray=E7=B1=BB=E5=AE=9E=E7=8E=B0=EF=BC=9B2=EF=BC=89=E5=AF=B9=E4=
=BA=8ERow=E4=BC=98=E5=85=88=E6=8E=92=E5=BA=8F=E7=9A=84=E9=93=BE=E8=A1=A8=E8=
=80=8C=E8=A8=80=EF=BC=8C=E5=8D=95=E7=8B=AC=E6=8F=90=E4=BE=9B=E4=BA=86GetF=
irstElementOfRow=E6=96=B9=E6=B3=95=E3=80=823=EF=BC=89=E5=AF=B9=E4=BA=8ECo=
lumn=E4=BC=98=E5=85=88=E6=8E=92=E5=BA=8F=E7=9A=84=E9=93=BE=E8=A1=A8=E8=80=
=8C=E8=A8=80=EF=BC=8C=E5=8D=95=E7=8B=AC=E6=8F=90=E4=BE=9B=E4=BA=86GetFirs=
tElementOfColumn=E6=96=B9=E6=B3=95=E3=80=82</P>
<P>RowFirstDynamicArray=E7=B1=BB=E7=9A=84=E5=AE=9E=E7=8E=B0=E5=A6=82=E4=B8=
=8B=EF=BC=9A</P>
<DIV class=3Dcode>
<DIV class=3Dtitle>
<DIV style=3D"FLOAT: right"><IMG class=3DcopyCodeImage=20
src=3D"http://www.cnblogs.com/images/cnblogs_com/zhenyulu/200701/copycode=
.gif"=20
align=3DabsMiddle name=3DccImage> <A onclick=3DCopyCode(this) =
href=3D"javascript:">Copy=20
Code</A></DIV>
<DIV style=3D"CLEAR: none">RowFirstDynamicArray.cs =
=E7=A8=8B=E5=BA=8F</DIV></DIV>
<DIV class=3Dcontent><SPAN style=3D"COLOR: #0000ff">public</SPAN> <SPAN=20
style=3D"COLOR: #0000ff">class</SPAN> RowFirstDynamicArray<T> :=20
DynamicArray<T> <BR>{ <BR> <SPAN=20
style=3D"COLOR: =
#008000">//=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=20
</SPAN><BR> <SPAN style=3D"COLOR: #008000">// =
=E6=9F=A5=E6=89=BE=E8=A1=8C=E4=B8=BA nRow =
=E7=9A=84=E7=AC=AC=E4=B8=80=E4=B8=AA=E7=BB=93=E7=82=B9=20
</SPAN><BR> <SPAN=20
style=3D"COLOR: =
#008000">//=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=20
</SPAN><BR> <SPAN style=3D"COLOR: #0000ff">public</SPAN>=20
ChainItem<T> GetFirstElementOfRow(<SPAN style=3D"COLOR: =
#0000ff">int</SPAN>=20
nRow) <BR> { <BR> =
ChainItem<T>=20
pCur =3D pHead; <BR><BR> <SPAN=20
style=3D"COLOR: #0000ff">while</SPAN> (pCur !=3D <SPAN=20
style=3D"COLOR: #0000ff">null</SPAN> && pCur.row !=3D nRow)=20
<BR> pCur =3D pCur.next; =
<BR><BR> <SPAN=20
style=3D"COLOR: #0000ff">return</SPAN> pCur; <BR> }=20
<BR><BR> <SPAN=20
style=3D"COLOR: =
#008000">//=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=20
</SPAN><BR> <SPAN style=3D"COLOR: #008000">// =E4=BB=8E =
startFrom =
=E5=A4=84=E5=90=91=E5=90=8E=E6=9F=A5=E6=89=BE=E8=A1=8C=E4=B8=BA nRow=20
=E7=9A=84=E7=AC=AC=E4=B8=80=E4=B8=AA=E7=BB=93=E7=82=B9 =
</SPAN><BR> <SPAN=20
style=3D"COLOR: =
#008000">//=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=20
</SPAN><BR> <SPAN style=3D"COLOR: #0000ff">public</SPAN>=20
ChainItem<T> GetFirstElementOfRow(<SPAN style=3D"COLOR: =
#0000ff">int</SPAN>=20
nRow, ChainItem<T> startFrom) <BR> {=20
<BR> ChainItem<T> pCur =3D =
startFrom;=20
<BR><BR> <SPAN style=3D"COLOR: =
#0000ff">while</SPAN>=20
(pCur !=3D <SPAN style=3D"COLOR: #0000ff">null</SPAN> && =
pCur.row !=3D nRow)=20
<BR> pCur =3D pCur.next; =
<BR><BR> <SPAN=20
style=3D"COLOR: #0000ff">return</SPAN> pCur; <BR> }=20
<BR><BR> <SPAN=20
style=3D"COLOR: =
#008000">//=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=20
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -