📄 slide0036.htm
字号:
src="slide0036_image019.gif" alt="文本框: 自定义的向量类初步设计" style='position:absolute;
top:5.5%;left:2.05%;width:8.42%;height:87.5%'><![endif]>
<div v:shape="_x0000_s44036" class=O style='mso-line-spacing:"100 50 0";
position:absolute;top:41.5%;left:-22.65%;width:64.98%;height:7.0%;visibility:
hidden'><span lang=ZH-CN style='font-family:宋体;mso-fareast-font-family:宋体;
font-size:150%;text-shadow:auto;mso-ansi-language:EN-US'><b>自定义的</b></span><span
lang=ZH-CN style='font-family:宋体;mso-fareast-font-family:宋体;font-size:150%;
text-shadow:auto;color:#9966FF;mso-ansi-language:EN-US'><b>向量类初步设计</b></span></div>
<v:shape id="_x0000_s44037" type="#_x0000_t202" style='position:absolute;
left:96pt;top:24pt;width:612pt;height:93.5pt' filled="f" fillcolor="#0cc [4]"
stroked="f" strokecolor="white [1]">
<v:fill color2="#33f [0]"/>
<v:shadow color="black [2]"/>
<v:textbox style='mso-fit-shape-to-text:t'/>
</v:shape>
<div v:shape="_x0000_s44037" class=O style='mso-line-spacing:"100 50 0"'><span
style='position:absolute;top:5.5%;left:14.41%;width:99.25%;height:5.25%'><span
lang=ZH-CN style='font-family:宋体;mso-fareast-font-family:宋体;mso-ansi-language:
EN-US'>根据</span><span lang=EN-US style='mso-fareast-language:ZH-CN'>Java</span><span
lang=ZH-CN style='font-family:宋体;mso-fareast-font-family:宋体;mso-ansi-language:
EN-US'>中提供的向量类的基本特征,可以设计一个具有</span></span><span style='position:absolute;
top:10.75%;left:14.41%;width:99.25%;height:5.25%'><span lang=ZH-CN
style='font-family:宋体;mso-fareast-font-family:宋体;mso-ansi-language:EN-US'>类似功能的类,以便加深对于向量类的理解。</span><span
lang=EN-US style='mso-fareast-language:ZH-CN'>Java</span><span lang=ZH-CN
style='font-family:宋体;mso-fareast-font-family:宋体;mso-ansi-language:EN-US'>中向量</span></span><span
style='position:absolute;top:16.0%;left:14.41%;width:83.14%;height:5.25%'><span
lang=ZH-CN style='font-family:宋体;mso-fareast-font-family:宋体;mso-ansi-language:
EN-US'>类</span><span lang=EN-US style='mso-fareast-language:ZH-CN'>Vector</span><span
lang=ZH-CN style='font-family:宋体;mso-fareast-font-family:宋体;mso-ansi-language:
EN-US'>参见</span><span lang=EN-US style='mso-fareast-language:ZH-CN'>JDK</span><span
lang=ZH-CN style='font-family:宋体;mso-fareast-font-family:宋体;mso-ansi-language:
EN-US'>帮助文件有关内容。</span></span></div>
<!--[if !vml]><v:shapetype id="_x0000_t201" coordsize="21600,21600" o:spt="201"
path="m,l,21600r21600,l21600,xe">
<v:stroke joinstyle="miter"/>
<v:path shadowok="f" o:extrusionok="f" strokeok="f" fillok="f" o:connecttype="rect"/>
<o:lock v:ext="edit" shapetype="t"/>
</v:shapetype><v:shape id="_x0000_s44038" type="#_x0000_t201" style='position:absolute;
left:90pt;top:132pt;width:624pt;height:390pt;mso-wrap-style:none;
v-text-anchor:middle' strokecolor="red" strokeweight="2.25pt">
<![if gte mso 9]><v:imagedata src="slide0036_image001.wmz" o:title=""/>
<![endif]><v:shadow color="black [2]"/>
<o:lock v:ext="edit" text="t"/>
</v:shape><![endif]--><![if !ppt]>
<div style='position:absolute;top:24.5%;left:12.54%;width:86.89%;height:72.5%'><![endif]><object
classid="CLSID:8BD21D10-EC42-11CE-9E0D-00AA006002F3" id=TextBox1
v:shapes="_x0000_s44038" width="100%" height="100%">
<param name=VariousPropertyBits value=2894088219>
<param name=BackColor value=12640511>
<param name=ScrollBars value=3>
<param name=Size value="22013;13758">
<param name=Value
value="public class MyVector{ private Object[] elementData; private int elementCount; public MyVector(){ this(10); } public MyVector(int initialCapacity){ elementData = new Object[initialCapacity]; elementCount = 0; } public void add(int index,Object element){ if (index >= elementCount + 1) { throw new ArrayIndexOutOfBoundsException(index + " > " + elementCount); } ensureCapacity(elementCount + 1); System.arraycopy(elementData, index, elementData, index + 1, elementCount - index); elementData[index] = element; elementCount++; } public void add(Object element){ add(elementCount,element); } public void set(int index,Object element){ if (index >= elementCount) { throw new ArrayIndexOutOfBoundsException(index + " >= " + elementCount); } elementData[index] = element; } public Object get(int index){ if (index >= elementCount) throw new ArrayIndexOutOfBoundsException(index); return elementData[index]; } public int size(){ return elementCount; } public int indexOf(Object element){ if (element == null) { for (int i = 0 ; i < elementCount ; i++) if (elementData[i] == null) return i; } else { for (int i = 0 ; i < elementCount ; i++) if (element.equals(elementData[i])) return i; } return -1; } public void remove(Object obj){ int i = indexOf(obj); if (i >= 0) { remove(i); } } public boolean contain(Object element){ return indexOf(element) >= 0; } private void ensureCapacity(int minCapacity){ int oldCapacity = elementData.length; if (minCapacity > oldCapacity) { Object oldData[] = elementData; int newCapacity = oldCapacity * 2; if (newCapacity < minCapacity) { newCapacity = minCapacity; } elementData = new Object[newCapacity]; System.arraycopy(oldData, 0, elementData, 0, elementCount); } } public void remove(int index){ if (index >= elementCount) { throw new ArrayIndexOutOfBoundsException(index + " >= " + elementCount); } else if (index < 0) { throw new ArrayIndexOutOfBoundsException(index); } int j = elementCount - index - 1; if (j > 0) { System.arraycopy(elementData, index + 1, elementData, index, j); } elementCount--; elementData[elementCount] = null; } // public void trimToSzie(){ // int oldCapacity = elementData.length; // if (elementCount < oldCapacity) { // Object oldData[] = elementData; // elementData = new Object[elementCount]; // System.arraycopy(oldData, 0, elementData, 0, elementCount); // } // } // public Object[] toArray(){ // Object[] result = new Object[elementCount]; // System.arraycopy(elementData, 0, result, 0, elementCount); // return result; // } /* public void removeAll(){ for (int i = 0; i < elementCount; i++) elementData[i] = null; elementCount = 0; } */ // public static void vectorCopy(MyVector src,int possrc,MyVector dst,int posdst,int count){ // int length1 = src.size(); // int length2 = dst.size(); // if(length1 - possrc < count || length2 - posdst < count) // throw new ArrayIndexOutOfBoundsException(count); // for(int i = 0;i < src.size();i ++){ // dst.add(src.get(i)); // } // } // public String toString(){ // String str=""; // for(int i = 0;i < elementCount;i ++){ // str = str + get(i).toString() + " "; // } // return str; // } }">
<param name=FontName value="Arial Black">
<param name=FontHeight value=360>
<param name=FontCharSet value=0>
<param name=FontPitchAndFamily value=34>
<param name=Text
value="public class MyVector{ private Object[] elementData; private int elementCount; public MyVector(){ this(10); } public MyVector(int initialCapacity){ elementData = new Object[initialCapacity]; elementCount = 0; } public void add(int index,Object element){ if (index >= elementCount + 1) { throw new ArrayIndexOutOfBoundsException(index + " > " + elementCount); } ensureCapacity(elementCount + 1); System.arraycopy(elementData, index, elementData, index + 1, elementCount - index); elementData[index] = element; elementCount++; } public void add(Object element){ add(elementCount,element); } public void set(int index,Object element){ if (index >= elementCount) { throw new ArrayIndexOutOfBoundsException(index + " >= " + elementCount); } elementData[index] = element; } public Object get(int index){ if (index >= elementCount) throw new ArrayIndexOutOfBoundsException(index); return elementData[index]; } public int size(){ return elementCount; } public int indexOf(Object element){ if (element == null) { for (int i = 0 ; i < elementCount ; i++) if (elementData[i] == null) return i; } else { for (int i = 0 ; i < elementCount ; i++) if (element.equals(elementData[i])) return i; } return -1; } public void remove(Object obj){ int i = indexOf(obj); if (i >= 0) { remove(i); } } public boolean contain(Object element){ return indexOf(element) >= 0; } private void ensureCapacity(int minCapacity){ int oldCapacity = elementData.length; if (minCapacity > oldCapacity) { Object oldData[] = elementData; int newCapacity = oldCapacity * 2; if (newCapacity < minCapacity) { newCapacity = minCapacity; } elementData = new Object[newCapacity]; System.arraycopy(oldData, 0, elementData, 0, elementCount); } } public void remove(int index){ if (index >= elementCount) { throw new ArrayIndexOutOfBoundsException(index + " >= " + elementCount); } else if (index < 0) { throw new ArrayIndexOutOfBoundsException(index); } int j = elementCount - index - 1; if (j > 0) { System.arraycopy(elementData, index + 1, elementData, index, j); } elementCount--; elementData[elementCount] = null; } // public void trimToSzie(){ // int oldCapacity = elementData.length; // if (elementCount < oldCapacity) { // Object oldData[] = elementData; // elementData = new Object[elementCount]; // System.arraycopy(oldData, 0, elementData, 0, elementCount); // } // } // public Object[] toArray(){ // Object[] result = new Object[elementCount]; // System.arraycopy(elementData, 0, result, 0, elementCount); // return result; // } /* public void removeAll(){ for (int i = 0; i < elementCount; i++) elementData[i] = null; elementCount = 0; } */ // public static void vectorCopy(MyVector src,int possrc,MyVector dst,int posdst,int count){ // int length1 = src.size(); // int length2 = dst.size(); // if(length1 - possrc < count || length2 - posdst < count) // throw new ArrayIndexOutOfBoundsException(count); // for(int i = 0;i < src.size();i ++){ // dst.add(src.get(i)); // } // } // public String toString(){ // String str=""; // for(int i = 0;i < elementCount;i ++){ // str = str + get(i).toString() + " "; // } // return str; // } }">
</object><![if !ppt]></div>
<![endif]><p:shaperange href="master04.xml#_x0000_m5154"/><v:shape id="_x0000_s44039"
type="#_x0000_m5154" style='position:absolute;left:90pt;top:48pt;width:612pt;
height:90pt' o:userdrawn="f">
<v:fill o:detectmouseclick="t"/>
<v:stroke o:forcedash="t"/>
<o:lock v:ext="edit" text="f"/>
<p:placeholder type="title"/></v:shape>
<div v:shape="_x0000_s44039" class=T><span style='position:absolute;
top:13.75%;left:13.48%;width:83.14%;height:8.5%'><span lang=ZH-CN
style='font-family:宋体;mso-fareast-font-family:宋体;mso-ansi-language:EN-US;
mso-special-format:lastCR;display:none'> </span></span></div>
</p:slide></div>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -