How to use the tstl.Vector function in tstl

To help you get started, we’ve selected a few tstl examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github samchon / framework / src / protocol / entity / IEntityGroup.ts View on Github external
export function construct,
			IteratorT extends std.base.Iterator,
			ReverseT extends std.base.ReverseIterator>
		(entityGroup: IEntityGroup, xml: XML, ...prohibited_names: string[]): void
	{
		entityGroup.clear();

		// MEMBER VARIABLES
		IEntity.construct(entityGroup, xml, ...prohibited_names);

		// CHILDREN
		if (xml.has(entityGroup.CHILD_TAG()) == false)
			return;

		let children: std.Vector = new std.Vector();
		let xml_list: XMLList = xml.get(entityGroup.CHILD_TAG());

		for (let i: number = 0; i < xml_list.size(); i++) 
		{
			let child: T = entityGroup.createChild(xml_list.at(i));
			if (child == null)
				continue;

			child.construct(xml_list.at(i));
			children.push(child);
		}
		entityGroup.assign(children.begin(), children.end());
	}
github samchon / framework / src / templates / parallel / ParallelSystemArray.ts View on Github external
// WRONG TYPE
		if ((history instanceof PRInvokeHistory) == false)
			return false;

		let uid: number = history.getUID();

		// ALL THE SUB-TASKS ARE DONE?
		for (let i: number = 0; i < this.size(); i++)
			if (this.at(i)["progress_list_"].has(uid) == true)
				return false; // IT'S ON A PROCESS IN SOME SYSTEM.

		//--------
		// RE-CALCULATE PERFORMANCE INDEX
		//--------
		// CONSTRUCT BASIC DATA
		let system_pairs = new std.Vector>();
		let performance_index_average: number = 0.0;

		for (let i: number = 0; i < this.size(); i++)
		{
			let system: ParallelSystem = this.at(i);
			if (system["history_list_"].has(uid) == false)
				continue; // NO HISTORY (HAVE NOT PARTICIPATED IN THE PARALLEL PROCESS)

			// COMPUTE PERFORMANCE INDEX BASIS ON EXECUTION TIME OF THIS PARALLEL PROCESS
			let my_history: PRInvokeHistory = system["history_list_"].get(uid) as PRInvokeHistory;
			let performance_index: number = my_history.computeSize() / my_history.computeElapsedTime();

			// PUSH TO SYSTEM PAIRS AND ADD TO AVERAGE
			system_pairs.push_back(std.make_pair(system, performance_index));
			performance_index_average += performance_index;
		}
github samchon / framework / src / templates / parallel / ParallelSystemArray.ts View on Github external
if (invoke.has("_History_uid") == false)
			invoke.push_back(new InvokeParameter("_History_uid", ++this.history_sequence_));
		else
		{
			// INVOKE MESSAGE ALREADY HAS ITS OWN UNIQUE ID
			//	- THIS IS A TYPE OF ParallelSystemArrayMediator. THE MESSAGE HAS COME FROM ITS MASTER
			//	- A ParallelSystem HAS DISCONNECTED. THE SYSTEM SHIFTED ITS CHAIN TO OTHER SLAVES.
			let uid: number = invoke.get("_History_uid").getValue();

			// FOR CASE 1. UPDATE HISTORY_SEQUENCE TO MAXIMUM
			if (uid > this.history_sequence_)
				this.history_sequence_ = uid;
		}

		let segment_size: number = last - first; // TOTAL NUMBER OF PIECES TO DIVIDE
		let candidate_systems: std.Vector = new std.Vector(); // SYSTEMS TO BE GET DIVIDED PROCESSES
		let participants_count: number = 0;

		// POP EXCLUDEDS
		for (let i: number = 0; i < this.size(); i++)
			if (this.at(i)["exclude_"] == false)
				candidate_systems.push(this.at(i));

		// ORDERS
		for (let i: number = 0; i < candidate_systems.size(); i++)
		{
			let system: ParallelSystem = candidate_systems.at(i);
			
			// COMPUTE FIRST AND LAST INDEX TO ALLOCATE
			let piece_size: number = (i == candidate_systems.size() - 1) 
				? segment_size - first
				: Math.floor(segment_size / candidate_systems.size() * system.getPerformance());