1. 程式人生 > >向量指令和標量指令

向量指令和標量指令

actor 基本 .get 對象 oid dom nod 文件的 imp

向量指令和標量指令:有些大型機和巨型機 設置功能齊全的向量運算指令系統。

向量指令的基本操作對象是向量,即有序排列的一組數。

若指令為向量操作,則由指令確定向量操作數的地址(主存儲器起始地址或向量寄存器號),並直接或隱含地指定如增量、向量長度等其他向量參數。

向量指令規定處理機按同一操作處理向量中的所有分量,可有效地提高計算機的運算速度。

不具備向量處理功能,只對單個量即標量進行操作的指令稱為標量指令。

 1 package Com.TableTest;
 2 
 3 import java.io.File;  
 4 import javax.xml.parsers.DocumentBuilder;  
5 import javax.xml.parsers.DocumentBuilderFactory; 6 import org.w3c.dom.Document; 7 import org.w3c.dom.Element; 8 import org.w3c.dom.Node; 9 import org.w3c.dom.NodeList; 10 11 public class TableText_07 { 12 13 public void getAllUserNames(String fileName) { 14 try {
15 DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); 16 DocumentBuilder db = dbf.newDocumentBuilder(); 17 File file = new File(fileName); 18 if (file.exists()) { 19 Document doc = db.parse(file); 20 Element docEle = doc.getDocumentElement();
21 22 // Print root element of the document 23 System.out.println("Root element of the document: " 24 + docEle.getNodeName()); 25 26 NodeList studentList = docEle.getElementsByTagName("student"); 27 28 // Print total student elements in document 29 System.out 30 .println("Total students: " + studentList.getLength()); 31 32 if (studentList != null && studentList.getLength() > 0) { 33 for (int i = 0; i < studentList.getLength(); i++) { 34 35 Node node = studentList.item(i); 36 37 if (node.getNodeType() == Node.ELEMENT_NODE) { 38 39 System.out 40 .println("====================="); 41 42 Element e = (Element) node; 43 NodeList nodeList = e.getElementsByTagName("name"); 44 System.out.println("Name: " 45 + nodeList.item(0).getChildNodes().item(0) 46 .getNodeValue()); 47 48 nodeList = e.getElementsByTagName("grade"); 49 System.out.println("Grade: " 50 + nodeList.item(0).getChildNodes().item(0) 51 .getNodeValue()); 52 53 nodeList = e.getElementsByTagName("age"); 54 System.out.println("Age: " 55 + nodeList.item(0).getChildNodes().item(0) 56 .getNodeValue()); 57 } 58 } 59 } else { 60 System.exit(1); 61 } 62 } 63 } catch (Exception e) { 64 System.out.println(e); 65 } 66 } 67 public static void main(String[] args) { 68 69 TableText_07 parser = new TableText_07(); 70 parser.getAllUserNames("H:\\test2.xml"); 71 } 72 }

parser.getAllUserNames("H:\\test2.xml"); 測試獲取的文件
 1 <?xml version="1.0"?> 
 2 <students> 
 3     <student> 
 4         <name>borter</name> 
 5         <grade>A</grade> 
 6         <age>22</age> 
 7     </student> 
 8     <student> 
 9         <name>Mary</name> 
10         <grade>B</grade> 
11         <age>23</age> 
12     </student> 
13     <student> 
14         <name>Tom</name> 
15         <grade>c</grade> 
16         <age>24</age> 
17     </student> 
18 </students>
測試獲取的文件的結果集:
 1 Root element of the document: students
 2 Total students: 3
 3 =====================
 4 Name: borter
 5 Grade: A
 6 Age: 22
 7 =====================
 8 Name: Mary
 9 Grade: B
10 Age: 23
11 =====================
12 Name: Tom
13 Grade: c
14 Age: 24

向量指令和標量指令