JAVA一些函數問題

1.vertexMap.get()

2.vertexMap.put( vertexName, v )

3.vertexMap.values()

4.st.countTokens( )

5.st.nextToken( )

6.vertexMap.size( )

7.宣告 Vector<Vertex> v ， v.elementAt(i)

8.宣告 Vector<Vertex> v ， v.removeElementAt(0)

9.宣告 Queue<Vertex> q = new LinkedList<Vertex>( ) ， q.isEmpty( )

10.宣告 Queue<Vertex> q = new LinkedList<Vertex>( ) ， q.contains( )

Rating

相關Package都在以下網址

http://www.cs.fiu.edu/~weiss/dsj2/docs/weiss/util/...

=====================================================

以下為各函式說明:

1.vertexMap.get()

2.vertexMap.put( vertexName, v )

3.vertexMap.values()

6.vertexMap.size( )

http://www.cs.fiu.edu/~weiss/dsj2/docs/weiss/util/...

java.lang.Object

get(java.lang.Object key)

Returns the value in the map associated with the key.

java.lang.Object

put(java.lang.Object key, java.lang.Object value)

Adds the key value pair to the map, overriding the original value if the key was already present.

Collection

values()

Returns the values in the map.

int

size()

Returns the number of keys in this map.

=========================================================

4.st.countTokens( )

5.st.nextToken( )

http://java.sun.com/j2se/1.5.0/docs/api/java/util/...

int

countTokens()

Calculates the number of times that this tokenizer's nextToken method can be called before it generates an exception.

String

nextToken()

Returns the next token from this string tokenizer.

========================================================

7.宣告 Vector<Vertex> v ， v.elementAt(i)

8.宣告 Vector<Vertex> v ， v.removeElementAt(0)

9.宣告 Queue<Vertex> q = new LinkedList<Vertex>( ) ， q.isEmpty( )

10.宣告 Queue<Vertex> q = new LinkedList<Vertex>( ) ， q.contains( )

這些是在宣告Vector和Queue時，將其泛型設定為Vertex

http://www.cs.fiu.edu/~weiss/dsj2/docs/weiss/util/...

containspublic boolean contains(java.lang.Object x)

Tests if some item is in this collection.

Specified by:

contains in interface Collection

Overrides:

contains in class AbstractCollection

Parameters:

x - any object.

Returns:

true if this collection contains an item equal to x.

isEmptypublic boolean isEmpty()

Tests if this collection is empty.

Specified by:

isEmpty in interface Collection

Returns:

true if the size of this collection is zero.

Source(s): 自己+weiss jsd2

http://mail.im.tku.edu.tw/~seke/course07/oop/weiss...

2007-12-14 01:20:06 補充：

原始碼如上

我們需要原始碼。