浏览代码

finished documentation of haxe.ds

Simon Krajewski 12 年之前
父节点
当前提交
040d3c4e9e
共有 5 个文件被更改,包括 126 次插入49 次删除
  1. 12 13
      std/haxe/ds/IntMap.hx
  2. 40 0
      std/haxe/ds/ObjectMap.hx
  3. 11 14
      std/haxe/ds/StringMap.hx
  4. 23 21
      std/haxe/ds/Vector.hx
  5. 40 1
      std/haxe/ds/WeakMap.hx

+ 12 - 13
std/haxe/ds/IntMap.hx

@@ -22,50 +22,49 @@
 package haxe.ds;
 
 /**
-	Hashtable over a set of elements, using [Int] as keys.
-	On Flash and Javascript, the underlying structure is an Object.
+	IntMap allows mapping of Int keys to arbitrary values.
+	
+	See `Map` for documentation details.
 **/
 extern class IntMap<T> implements Map.IMap<Int,T> {
 
 	/**
-		Creates a new empty hashtable.
+		Creates a new IntMap.
 	**/
 	public function new() : Void;
 
 	/**
-		Set a value for the given key.
+		See `Map.set`
 	**/
 	public function set( key : Int, value : T ) : Void;
+	
 	/**
-		Get a value for the given key.
+		See `Map.get`
 	**/
 	public function get( key : Int ) : Null<T>;
 
 	/**
-		Tells if a value exists for the given key.
-		In particular, it's useful to tells if a key has
-		a [null] value versus no value.
+		See `Map.exists`
 	**/
 	public function exists( key : Int ) : Bool;
 
 	/**
-		Removes a hashtable entry. Returns [true] if
-		there was such entry.
+		See `Map.remove`
 	**/
 	public function remove( key : Int ) : Bool;
 
 	/**
-		Returns an iterator of all keys in the hashtable.
+		See `Map.keys`
 	**/
 	public function keys() : Iterator<Int>;
 
 	/**
-		Returns an iterator of all values in the hashtable.
+		See `Map.iterator`
 	**/
 	public function iterator() : Iterator<T>;
 
 	/**
-		Returns an displayable representation of the hashtable content.
+		See `Map.toString`
 	**/
 	public function toString() : String;
 

+ 40 - 0
std/haxe/ds/ObjectMap.hx

@@ -22,13 +22,53 @@
 
 package haxe.ds;
 
+/**
+	ObjectMap allows mapping of object keys to arbitrary values.
+	
+	On static targets, the keys are considered to be strong references. Refer
+	to `haxe.ds.WeakMap` for a weak reference version.
+	
+	See `Map` for documentation details.
+**/
 extern class ObjectMap < K: { }, V > implements Map.IMap<K,V> {
+	
+	/**
+		Creates a new ObjectMap.
+	**/
 	public function new():Void;
+	
+	/**
+		See `Map.set`
+	**/
 	public function set(key:K, value:V):Void;
+	
+	/**
+		See `Map.get`
+	**/	
 	public function get(key:K):Null<V>;
+	
+	/**
+		See `Map.exists`
+	**/	
 	public function exists(key:K):Bool;
+	
+	/**
+		See `Map.remove`
+	**/	
 	public function remove(key:K):Bool;
+	
+	/**
+		See `Map.keys`
+	**/	
 	public function keys():Iterator<K>;
+	
+	/**
+		See `Map.iterator`
+	**/	
 	public function iterator():Iterator<V>;
+	
+	/**
+		See `Map.toString`
+	**/	
 	public function toString():String;
 }

+ 11 - 14
std/haxe/ds/StringMap.hx

@@ -23,52 +23,49 @@
 package haxe.ds;
 
 /**
-	Hashtable over a set of elements, using [String] as keys.
-	Other kind of keys are not possible on all platforms since they
-	can't always be implemented efficiently.
+	StringMap allows mapping of String keys to arbitrary values.
+	
+	See `Map` for documentation details.
 **/
 extern class StringMap<T> implements Map.IMap<String,T> {
 
 	/**
-		Creates a new empty hashtable.
+		Creates a new StringMap.
 	**/
 	public function new() : Void;
 
 	/**
-		Set a value for the given key.
+		See `Map.set`
 	**/
 	public function set( key : String, value : T ) : Void;
 
 	/**
-		Get a value for the given key.
+		See `Map.get`
 	**/
 	public function get( key : String ) : Null<T>;
 
 	/**
-		Tells if a value exists for the given key.
-		In particular, it's useful to tells if a key has
-		a [null] value versus no value.
+		See `Map.exists`
 	**/
 	public function exists( key : String ) : Bool;
 
 	/**
-		Removes a hashtable entry. Returns [true] if
-		there was such entry.
+		See `Map.remove`
 	**/
 	public function remove( key : String ) : Bool;
 
 	/**
-		Returns an iterator of all keys in the hashtable.
+		See `Map.keys`
 	**/
 	public function keys() : Iterator<String>;
 
 	/**
-		Returns an iterator of all values in the hashtable.
+		See `Map.iterator`
 	**/
 	public function iterator() : Iterator<T>;
 
 	/**
-		Returns an displayable representation of the hashtable content.
+		See `Map.toString`
 	**/
 	public function toString() : String;
 

+ 23 - 21
std/haxe/ds/Vector.hx

@@ -40,15 +40,15 @@ private typedef VectorData<T> = #if flash10
 @:arrayAccess
 abstract Vector<T>(VectorData<T>) {
 	/**
-		Creates a new Vector of length [length].
+		Creates a new Vector of length `length`.
 
-		Initially [this] Vector contains [length] neutral elements:
-			- always null on dynamic targets
-			- 0, 0.0 or false for Int, Float and Bool respectively on static
-			targets
-			- null for other types on static targets
+		Initially `this` Vector contains `length` neutral elements:
+			
+		- always null on dynamic targets
+		- 0, 0.0 or false for Int, Float and Bool respectively on static targets
+		- null for other types on static targets
 
-		If [length] is less than or equal to 0, the result is unspecified.
+		If `length` is less than or equal to 0, the result is unspecified.
 	**/
 	public inline function new(length:Int) {
 		#if flash9
@@ -70,9 +70,9 @@ abstract Vector<T>(VectorData<T>) {
 	}
 
 	/**
-		Returns the value at index [index].
+		Returns the value at index `index`.
 
-		If [index] is negative or exceeds [this].length, the result is
+		If `index` is negative or exceeds `this.length`, the result is
 		unspecified.
 	**/
 	public inline function get(index:Int):Null<T> {
@@ -80,9 +80,9 @@ abstract Vector<T>(VectorData<T>) {
 	}
 
 	/**
-		Sets the value at index [index] to [val].
+		Sets the value at index `index` to `val`.
 
-		If [index] is negative or exceeds [this].length, the result is
+		If `index` is negative or exceeds `this.length`, the result is
 		unspecified.
 	**/
 	public inline function set(index:Int, val:T):T {
@@ -90,7 +90,7 @@ abstract Vector<T>(VectorData<T>) {
 	}
 
 	/**
-		Returns the length of [this] Vector.
+		Returns the length of `this` Vector.
 	**/
 	public var length(get, never):Int;
 
@@ -107,9 +107,11 @@ abstract Vector<T>(VectorData<T>) {
 	}
 
 	/**
-		Copies [length] of elements from [src] Vector, beginning at [srcPos] to [dest] Vector, beginning at [destPos]
+		Copies `length` of elements from `src` Vector, beginning at `srcPos` to
+		`dest` Vector, beginning at `destPos`
 
-		The results are unspecified if [length] results in out-of-bounds access, or if [src] or [dest] are null
+		The results are unspecified if `length` results in out-of-bounds access,
+		or if `src` or `dest` are null
 	**/
 	public static #if (cs || java || neko) inline #end function blit<T>(src:Vector<T>, srcPos:Int, dest:Vector<T>, destPos:Int, len:Int):Void
 	{
@@ -128,7 +130,7 @@ abstract Vector<T>(VectorData<T>) {
 	}
 
 	/**
-		Extracts the data of [this] Vector.
+		Extracts the data of `this` Vector.
 
 		This returns the internal representation type.
 	**/
@@ -136,25 +138,25 @@ abstract Vector<T>(VectorData<T>) {
 		return cast this;
 
 	/**
-		Initializes a new Vector from [data].
+		Initializes a new Vector from `data`.
 
-		Since [data] is the internal representation of Vector, this is a no-op.
+		Since `data` is the internal representation of Vector, this is a no-op.
 
-		If [data] is null, the corresponding Vector is also [null].
+		If `data` is null, the corresponding Vector is also `null`.
 	**/
 	static public inline function fromData<T>(data:VectorData<T>):Vector<T>
 		return cast data;
 
 	/**
-		Creates a new Vector by copying the elements of [array].
+		Creates a new Vector by copying the elements of `array`.
 
 		This always creates a copy, even on platforms where the internal
 		representation is Array.
 
 		The elements are not copied and retain their identity, so
-		a[i] == Vector.fromArrayCopy(a).get(i) is true for any valid i.
+		`a[i] == Vector.fromArrayCopy(a).get(i)` is true for any valid i.
 
-		If [array] is null, the result is unspecified.
+		If `array` is null, the result is unspecified.
 	**/
 	static public inline function fromArrayCopy<T>(array:Array<T>):Vector<T> {
 		// TODO: Optimize this for flash (and others?)

+ 40 - 1
std/haxe/ds/WeakMap.hx

@@ -22,27 +22,66 @@
 
 package haxe.ds;
 
-class WeakMap<K:{},V> implements Map.IMap<K,V> {
+/**
+	WeakMap allows mapping of object keys to arbitrary values.
+	
+	The keys are considered to be weak references on static targets.
+	
+	See `Map` for documentation details.
+**/
+class WeakMap<K: { },V> implements Map.IMap<K,V> {
+	
+	/**
+		Creates a new WeakMap.
+	**/	
 	public function new():Void {
 		throw "Not implemented for this platform";
 	}
+	
+	/**
+		See `Map.set`
+	**/	
 	public function set(key:K, value:V):Void {
 	}
+	
+	/**
+		See `Map.get`
+	**/		
 	public function get(key:K):Null<V> {
 		return null;
 	}
+	
+	/**
+		See `Map.exists`
+	**/		
 	public function exists(key:K):Bool {
 		return false;
 	}
+	
+	/**
+		See `Map.remove`
+	**/		
 	public function remove(key:K):Bool {
 		return false;
 	}
+	
+	/**
+		See `Map.keys`
+	**/		
 	public function keys():Iterator<K> {
 		return null;
 	}
+	
+	/**
+		See `Map.iterator`
+	**/		
 	public function iterator():Iterator<V> {
 		return null;
 	}
+	
+	/**
+		See `Map.toString`
+	**/		
 	public function toString():String {
 		return null;
 	}