From 0ebac1ef817e65b965d67b1255df7283f46d4001 Mon Sep 17 00:00:00 2001 From: Jeongho Nam Date: Thu, 11 Aug 2016 16:35:40 +0900 Subject: [PATCH] TypeScript-STL & Samchon Framework --- samchon-framework/samchon-framework.d.ts | 4554 +++++++++++++++++----- typescript-stl/typescript-stl-tests.ts | 2 +- typescript-stl/typescript-stl.d.ts | 1357 +++---- 3 files changed, 4371 insertions(+), 1542 deletions(-) diff --git a/samchon-framework/samchon-framework.d.ts b/samchon-framework/samchon-framework.d.ts index c81a9d1e5b..a6d03758dd 100644 --- a/samchon-framework/samchon-framework.d.ts +++ b/samchon-framework/samchon-framework.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Samchon Framework v1.2.0 +// Type definitions for Samchon Framework v2.0.0-beta.1 // Project: https://github.com/samchon/framework // Definitions by: Jeongho Nam // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -11,28 +11,59 @@ declare module "samchon-framework" } /** - * Samchon Framework, A SDN framework. + *

Samchon-Framework

* + *

+ *

+ * + *

Samchon, a SDN (Software Defined Network) framework.

+ * + *

With Samchon Framework, you can implement distributed processing system within framework of OOD like + * handling S/W objects (classes). You can realize cloud and distributed system very easily with provided + * system templates and even integration with C++ is possible.

+ * + *

The goal, ultimate utilization model of Samchon Framework is, building cloud system with NodeJS and + * takING heavy works to C++ distributed systems with provided modules (those are system templates).

+ * + * @git https://github.com/samchon/framework * @author Jeongho Nam */ declare namespace samchon { -} -declare namespace samchon.library { -} -declare namespace samchon.collection { -} -declare namespace samchon.protocol { -} -declare namespace samchon.protocol.service { -} -declare namespace samchon.protocol.master { -} -declare namespace samchon.protocol.slave { + /** + *

Running on Node.

+ * + *

Test whether the JavaScript is running on Node.

+ * + * @references http://stackoverflow.com/questions/17575790/environment-detection-node-js-or-browser + */ + function is_node(): boolean; } declare namespace samchon.collection { /** * A {@link Vector} who can detect element I/O events. * + *
    + *
  • insert typed events:
      + *
    • {@link assign}
    • + *
    • {@link insert}
    • + *
    • {@link push}
    • + *
    • {@link push_back}
    • + *
    • {@link unshift}
    • + *
  • + *
  • erase typed events:
      + *
    • {@link assign}
    • + *
    • {@link clear}
    • + *
    • {@link erase}
    • + *
    • {@link pop_back}
    • + *
    • {@link shift}
    • + *
    • {@link pop}
    • + *
    • {@link splice}
    • + *
  • + *
  • erase typed events:
      + *
    • {@link sort}
    • + *
  • + *
+ * * @author Jeongho Nam */ class ArrayCollection extends std.Vector implements ICollection { @@ -80,38 +111,46 @@ declare namespace samchon.collection { * @inheritdoc */ dispatchEvent(event: Event): boolean; + /** + * @inheritdoc + */ + refresh(): void; + /** + * @inheritdoc + */ + refresh(it: std.VectorIterator): void; + /** + * @inheritdoc + */ + refresh(first: std.VectorIterator, last: std.VectorIterator): void; /** * @inheritdoc */ addEventListener(type: string, listener: EventListener): void; + addEventListener(type: "insert", listener: CollectionEventListener): void; + addEventListener(type: "erase", listener: CollectionEventListener): void; + addEventListener(type: "refresh", listener: CollectionEventListener): void; /** * @inheritdoc */ addEventListener(type: string, listener: EventListener, thisArg: Object): void; - /** - * @inheritdoc - */ - addEventListener(type: "insert" | "erase", listener: CollectionEventListener): void; - /** - * @inheritdoc - */ - addEventListener(type: "insert" | "erase", listener: CollectionEventListener, thisArg: Object): void; + addEventListener(type: "insert", listener: CollectionEventListener, thisArg: Object): void; + addEventListener(type: "erase", listener: CollectionEventListener, thisArg: Object): void; + addEventListener(type: "refresh", listener: CollectionEventListener, thisArg: Object): void; /** * @inheritdoc */ removeEventListener(type: string, listener: EventListener): void; + removeEventListener(type: "insert", listener: CollectionEventListener): void; + removeEventListener(type: "erase", listener: CollectionEventListener): void; + removeEventListener(type: "refresh", listener: CollectionEventListener): void; /** * @inheritdoc */ removeEventListener(type: string, listener: EventListener, thisArg: Object): void; - /** - * @inheritdoc - */ - removeEventListener(type: "insert" | "erase", listener: CollectionEventListener): void; - /** - * @inheritdoc - */ - removeEventListener(type: "insert" | "erase", listener: CollectionEventListener, thisArg: Object): void; + removeEventListener(type: "insert", listener: CollectionEventListener, thisArg: Object): void; + removeEventListener(type: "erase", listener: CollectionEventListener, thisArg: Object): void; + removeEventListener(type: "refresh", listener: CollectionEventListener, thisArg: Object): void; /** * @inheritdoc */ @@ -132,12 +171,9 @@ declare namespace samchon.collection { } declare namespace samchon.library { /** - * An event class. - * - *
    - *
  • Comments from - https://developer.mozilla.org/en-US/docs/Web/API/Event/
  • - *
+ * A basic event class of Samchon Framework. * + * @reference https://developer.mozilla.org/en-US/docs/Web/API/Event * @author Jeongho Nam */ class BasicEvent implements Event { @@ -231,51 +267,78 @@ declare namespace samchon.library { } declare namespace samchon.collection { /** - * Type of function pointer for {@link CollectionEvent CollectionEvents}. + * Type of function pointer for listener of {@link CollectionEvent CollectionEvents}. */ interface CollectionEventListener extends EventListener { (event: CollectionEvent): void; } +} +declare namespace samchon.collection { /** - * + * @author Jeongho Nam */ class CollectionEvent extends library.BasicEvent { - static INSERT: string; - static ERASE: string; /** - * + * @hidden */ private first_; /** - * + * @hidden */ private last_; /** + * Initialization Constructor. * - * - * @param type + * @param type Type of collection event. * @param first * @param last */ constructor(type: string, first: std.Iterator, last: std.Iterator); + constructor(type: "insert", first: std.Iterator, last: std.Iterator); + constructor(type: "erase", first: std.Iterator, last: std.Iterator); + constructor(type: "refresh", first: std.Iterator, last: std.Iterator); /** - * + * Get associative container. */ container: ICollection; /** - * + * Get range of the first. */ first: std.Iterator; /** - * + * Get range of the last. */ last: std.Iterator; } } +declare namespace samchon.collection.CollectionEvent { + const INSERT: string; + const ERASE: string; + const REFRESH: string; +} declare namespace samchon.collection { /** * A {@link Deque} who can detect element I/O events. * + *

Below are list of methods who are dispatching {@link CollectionEvent}:

+ * + *
    + *
  • insert typed events:
      + *
    • {@link assign}
    • + *
    • {@link insert}
    • + *
    • {@link push}
    • + *
    • {@link push_front}
    • + *
    • {@link push_back}
    • + *
  • + *
  • erase typed events:
      + *
    • {@link assign}
    • + *
    • {@link clear}
    • + *
    • {@link erase}
    • + *
    • {@link pop_front}
    • + *
    • {@link pop_back}
    • + *
  • + *
+ * * @author Jeongho Nam */ class DequeCollection extends std.Deque implements ICollection { @@ -323,44 +386,72 @@ declare namespace samchon.collection { * @inheritdoc */ dispatchEvent(event: Event): boolean; + /** + * @inheritdoc + */ + refresh(): void; + /** + * @inheritdoc + */ + refresh(it: std.DequeIterator): void; + /** + * @inheritdoc + */ + refresh(first: std.DequeIterator, last: std.DequeIterator): void; /** * @inheritdoc */ addEventListener(type: string, listener: EventListener): void; + addEventListener(type: "insert", listener: CollectionEventListener): void; + addEventListener(type: "erase", listener: CollectionEventListener): void; + addEventListener(type: "refresh", listener: CollectionEventListener): void; /** * @inheritdoc */ addEventListener(type: string, listener: EventListener, thisArg: Object): void; - /** - * @inheritdoc - */ - addEventListener(type: "insert" | "erase", listener: CollectionEventListener): void; - /** - * @inheritdoc - */ - addEventListener(type: "insert" | "erase", listener: CollectionEventListener, thisArg: Object): void; + addEventListener(type: "insert", listener: CollectionEventListener, thisArg: Object): void; + addEventListener(type: "erase", listener: CollectionEventListener, thisArg: Object): void; + addEventListener(type: "refresh", listener: CollectionEventListener, thisArg: Object): void; /** * @inheritdoc */ removeEventListener(type: string, listener: EventListener): void; + removeEventListener(type: "insert", listener: CollectionEventListener): void; + removeEventListener(type: "erase", listener: CollectionEventListener): void; + removeEventListener(type: "refresh", listener: CollectionEventListener): void; /** * @inheritdoc */ removeEventListener(type: string, listener: EventListener, thisArg: Object): void; - /** - * @inheritdoc - */ - removeEventListener(type: "insert" | "erase", listener: CollectionEventListener): void; - /** - * @inheritdoc - */ - removeEventListener(type: "insert" | "erase", listener: CollectionEventListener, thisArg: Object): void; + removeEventListener(type: "insert", listener: CollectionEventListener, thisArg: Object): void; + removeEventListener(type: "erase", listener: CollectionEventListener, thisArg: Object): void; + removeEventListener(type: "refresh", listener: CollectionEventListener, thisArg: Object): void; } } declare namespace samchon.collection { /** * A {@link HashMap} who can detect element I/O events. * + *
    + *
  • insert typed events:
      + *
    • {@link assign}
    • + *
    • {@link insert}
    • + *
    • {@link push}
    • + *
    • {@link set}
    • + *
    • {@link insert_or_assign}
    • + *
  • + *
  • erase typed events:
      + *
    • {@link assign}
    • + *
    • {@link clear}
    • + *
    • {@link erase}
    • + *
    • {@link extract}
    • + *
  • + *
  • refresh typed events:
      + *
    • {@link set}
    • + *
    • {@link insert_or_assign}
    • + *
  • + *
+ * * @author Jeongho Nam */ class HashMapCollection extends std.HashMap implements ICollection> { @@ -384,42 +475,65 @@ declare namespace samchon.collection { * @inheritdoc */ dispatchEvent(event: Event): boolean; + /** + * @inheritdoc + */ + refresh(): void; + /** + * @inheritdoc + */ + refresh(it: std.MapIterator): void; + /** + * @inheritdoc + */ + refresh(first: std.MapIterator, last: std.MapIterator): void; /** * @inheritdoc */ addEventListener(type: string, listener: EventListener): void; + addEventListener(type: "insert", listener: CollectionEventListener>): void; + addEventListener(type: "erase", listener: CollectionEventListener>): void; + addEventListener(type: "refresh", listener: CollectionEventListener>): void; /** * @inheritdoc */ addEventListener(type: string, listener: EventListener, thisArg: Object): void; - /** - * @inheritdoc - */ - addEventListener(type: "insert" | "erase", listener: CollectionEventListener): void; - /** - * @inheritdoc - */ - addEventListener(type: "insert" | "erase", listener: CollectionEventListener, thisArg: Object): void; + addEventListener(type: "insert", listener: CollectionEventListener>, thisArg: Object): void; + addEventListener(type: "erase", listener: CollectionEventListener>, thisArg: Object): void; + addEventListener(type: "refresh", listener: CollectionEventListener>, thisArg: Object): void; /** * @inheritdoc */ removeEventListener(type: string, listener: EventListener): void; + removeEventListener(type: "insert", listener: CollectionEventListener>): void; + removeEventListener(type: "erase", listener: CollectionEventListener>): void; + removeEventListener(type: "refresh", listener: CollectionEventListener>): void; /** * @inheritdoc */ removeEventListener(type: string, listener: EventListener, thisArg: Object): void; - /** - * @inheritdoc - */ - removeEventListener(type: "insert" | "erase", listener: CollectionEventListener): void; - /** - * @inheritdoc - */ - removeEventListener(type: "insert" | "erase", listener: CollectionEventListener, thisArg: Object): void; + removeEventListener(type: "insert", listener: CollectionEventListener>, thisArg: Object): void; + removeEventListener(type: "erase", listener: CollectionEventListener>, thisArg: Object): void; + removeEventListener(type: "refresh", listener: CollectionEventListener>, thisArg: Object): void; } +} +declare namespace samchon.collection { /** * A {@link HashMultiMap} who can detect element I/O events. * + *
    + *
  • insert typed events:
      + *
    • {@link assign}
    • + *
    • {@link insert}
    • + *
    • {@link push}
    • + *
  • + *
  • erase typed events:
      + *
    • {@link assign}
    • + *
    • {@link clear}
    • + *
    • {@link erase}
    • + *
  • + *
+ * * @author Jeongho Nam */ class HashMultiMapCollection extends std.HashMap implements ICollection> { @@ -443,47 +557,143 @@ declare namespace samchon.collection { * @inheritdoc */ dispatchEvent(event: Event): boolean; + /** + * @inheritdoc + */ + refresh(): void; + /** + * @inheritdoc + */ + refresh(it: std.MapIterator): void; + /** + * @inheritdoc + */ + refresh(first: std.MapIterator, last: std.MapIterator): void; /** * @inheritdoc */ addEventListener(type: string, listener: EventListener): void; + addEventListener(type: "insert", listener: CollectionEventListener>): void; + addEventListener(type: "erase", listener: CollectionEventListener>): void; + addEventListener(type: "refresh", listener: CollectionEventListener>): void; /** * @inheritdoc */ addEventListener(type: string, listener: EventListener, thisArg: Object): void; - /** - * @inheritdoc - */ - addEventListener(type: "insert" | "erase", listener: CollectionEventListener): void; - /** - * @inheritdoc - */ - addEventListener(type: "insert" | "erase", listener: CollectionEventListener, thisArg: Object): void; + addEventListener(type: "insert", listener: CollectionEventListener>, thisArg: Object): void; + addEventListener(type: "erase", listener: CollectionEventListener>, thisArg: Object): void; + addEventListener(type: "refresh", listener: CollectionEventListener>, thisArg: Object): void; /** * @inheritdoc */ removeEventListener(type: string, listener: EventListener): void; + removeEventListener(type: "insert", listener: CollectionEventListener>): void; + removeEventListener(type: "erase", listener: CollectionEventListener>): void; + removeEventListener(type: "refresh", listener: CollectionEventListener>): void; /** * @inheritdoc */ removeEventListener(type: string, listener: EventListener, thisArg: Object): void; + removeEventListener(type: "insert", listener: CollectionEventListener>, thisArg: Object): void; + removeEventListener(type: "erase", listener: CollectionEventListener>, thisArg: Object): void; + removeEventListener(type: "refresh", listener: CollectionEventListener>, thisArg: Object): void; + } +} +declare namespace samchon.collection { + /** + * A {@link HashMultiSet} who can detect element I/O events. + * + *
    + *
  • insert typed events:
      + *
    • {@link assign}
    • + *
    • {@link insert}
    • + *
    • {@link push}
    • + *
  • + *
  • erase typed events:
      + *
    • {@link assign}
    • + *
    • {@link clear}
    • + *
    • {@link erase}
    • + *
  • + *
+ * + * @author Jeongho Nam + */ + class HashMultiSetCollection extends std.HashMultiSet implements ICollection { + /** + * A chain object taking responsibility of dispatching events. + */ + private event_dispatcher_; /** * @inheritdoc */ - removeEventListener(type: "insert" | "erase", listener: CollectionEventListener): void; + hasEventListener(type: string): boolean; /** * @inheritdoc */ - removeEventListener(type: "insert" | "erase", listener: CollectionEventListener, thisArg: Object): void; + dispatchEvent(event: Event): boolean; + /** + * @inheritdoc + */ + refresh(): void; + /** + * @inheritdoc + */ + refresh(it: std.SetIterator): void; + /** + * @inheritdoc + */ + refresh(first: std.SetIterator, last: std.SetIterator): void; + /** + * @inheritdoc + */ + addEventListener(type: string, listener: EventListener): void; + addEventListener(type: "insert", listener: CollectionEventListener): void; + addEventListener(type: "erase", listener: CollectionEventListener): void; + addEventListener(type: "refresh", listener: CollectionEventListener): void; + /** + * @inheritdoc + */ + addEventListener(type: string, listener: EventListener, thisArg: Object): void; + addEventListener(type: "insert", listener: CollectionEventListener, thisArg: Object): void; + addEventListener(type: "erase", listener: CollectionEventListener, thisArg: Object): void; + addEventListener(type: "refresh", listener: CollectionEventListener, thisArg: Object): void; + /** + * @inheritdoc + */ + removeEventListener(type: string, listener: EventListener): void; + removeEventListener(type: "insert", listener: CollectionEventListener): void; + removeEventListener(type: "erase", listener: CollectionEventListener): void; + removeEventListener(type: "refresh", listener: CollectionEventListener): void; + /** + * @inheritdoc + */ + removeEventListener(type: string, listener: EventListener, thisArg: Object): void; + removeEventListener(type: "insert", listener: CollectionEventListener, thisArg: Object): void; + removeEventListener(type: "erase", listener: CollectionEventListener, thisArg: Object): void; + removeEventListener(type: "refresh", listener: CollectionEventListener, thisArg: Object): void; } } declare namespace samchon.collection { /** * A {@link HashSet} who can detect element I/O events. * + *
    + *
  • insert typed events:
      + *
    • {@link assign}
    • + *
    • {@link insert}
    • + *
    • {@link push}
    • + *
  • + *
  • erase typed events:
      + *
    • {@link assign}
    • + *
    • {@link clear}
    • + *
    • {@link erase}
    • + *
    • {@link extract}
    • + *
  • + *
+ * * @author Jeongho Nam */ - class HashSetCollection extends std.TreeSet implements ICollection { + class HashSetCollection extends std.HashSet implements ICollection { /** * A chain object taking responsibility of dispatching events. */ @@ -507,216 +717,175 @@ declare namespace samchon.collection { /** * @inheritdoc */ - addEventListener(type: string, listener: EventListener): void; + refresh(): void; /** * @inheritdoc */ - addEventListener(type: string, listener: EventListener, thisArg: Object): void; + refresh(it: std.SetIterator): void; /** * @inheritdoc */ - addEventListener(type: "insert" | "erase", listener: CollectionEventListener): void; - /** - * @inheritdoc - */ - addEventListener(type: "insert" | "erase", listener: CollectionEventListener, thisArg: Object): void; - /** - * @inheritdoc - */ - removeEventListener(type: string, listener: EventListener): void; - /** - * @inheritdoc - */ - removeEventListener(type: string, listener: EventListener, thisArg: Object): void; - /** - * @inheritdoc - */ - removeEventListener(type: "insert" | "erase", listener: CollectionEventListener): void; - /** - * @inheritdoc - */ - removeEventListener(type: "insert" | "erase", listener: CollectionEventListener, thisArg: Object): void; - } - class HashMultiSetCollection extends std.TreeMultiSet implements ICollection { - /** - * A chain object taking responsibility of dispatching events. - */ - private event_dispatcher_; - /** - * @inheritdoc - */ - hasEventListener(type: string): boolean; - /** - * @inheritdoc - */ - dispatchEvent(event: Event): boolean; + refresh(first: std.SetIterator, last: std.SetIterator): void; /** * @inheritdoc */ addEventListener(type: string, listener: EventListener): void; + addEventListener(type: "insert", listener: CollectionEventListener): void; + addEventListener(type: "erase", listener: CollectionEventListener): void; + addEventListener(type: "refresh", listener: CollectionEventListener): void; /** * @inheritdoc */ addEventListener(type: string, listener: EventListener, thisArg: Object): void; - /** - * @inheritdoc - */ - addEventListener(type: "insert" | "erase", listener: CollectionEventListener): void; - /** - * @inheritdoc - */ - addEventListener(type: "insert" | "erase", listener: CollectionEventListener, thisArg: Object): void; + addEventListener(type: "insert", listener: CollectionEventListener, thisArg: Object): void; + addEventListener(type: "erase", listener: CollectionEventListener, thisArg: Object): void; + addEventListener(type: "refresh", listener: CollectionEventListener, thisArg: Object): void; /** * @inheritdoc */ removeEventListener(type: string, listener: EventListener): void; + removeEventListener(type: "insert", listener: CollectionEventListener): void; + removeEventListener(type: "erase", listener: CollectionEventListener): void; + removeEventListener(type: "refresh", listener: CollectionEventListener): void; /** * @inheritdoc */ removeEventListener(type: string, listener: EventListener, thisArg: Object): void; - /** - * @inheritdoc - */ - removeEventListener(type: "insert" | "erase", listener: CollectionEventListener): void; - /** - * @inheritdoc - */ - removeEventListener(type: "insert" | "erase", listener: CollectionEventListener, thisArg: Object): void; + removeEventListener(type: "insert", listener: CollectionEventListener, thisArg: Object): void; + removeEventListener(type: "erase", listener: CollectionEventListener, thisArg: Object): void; + removeEventListener(type: "refresh", listener: CollectionEventListener, thisArg: Object): void; } } declare namespace samchon.collection { /** * An interface for {@link IContainer containers} who can detect element I/O events. * + *

Below are list of methods who are dispatching {@link CollectionEvent}:

+ * + *
    + *
  • insert typed events:
      + *
    • {@link assign}
    • + *
    • {@link insert}
    • + *
    • {@link push}
    • + *
  • + *
  • erase typed events:
      + *
    • {@link assign}
    • + *
    • {@link clear}
    • + *
    • {@link erase}
    • + *
  • + * * @author Jeongho Nam */ interface ICollection extends std.base.IContainer, library.IEventDispatcher { + /** + *

    Dispatch a {@link CollectionEvent} with refresh typed.

    + * + *

    {@link ICollection} dispatches {@link CollectionEvent} typed insert or erase whenever + * elements I/O has occured. However, unlike those elements I/O events, content change in element level can't be + * detected. There's no way to detect those events automatically by {@link IContainer}.

    + * + *

    If you want to dispatch those typed events (notifying change on contents in element level), you've to + * dispatch refresh typed event manually, by yourself. Call {@link refresh refresh()} with specified + * iterators who're pointing the elements whose content have changed. Then a {@link CollectionEvent} with + * refresh typed will be dispatched.

    + * + *

    If you don't specify any iterator, then the range of the refresh event will be all elements in this + * {@link ICollection collection}; {@link begin begin()} to {@link end end()}.

    + */ + refresh(): void; + /** + *

    Dispatch a {@link CollectionEvent} with refresh typed.

    + * + *

    {@link ICollection} dispatches {@link CollectionEvent} typed insert or erase whenever + * elements I/O has occured. However, unlike those elements I/O events, content change in element level can't be + * detected. There's no way to detect those events automatically by {@link IContainer}.

    + * + *

    If you want to dispatch those typed events (notifying change on contents in element level), you've to + * dispatch refresh typed event manually, by yourself. Call {@link refresh refresh()} with specified + * iterators who're pointing the elements whose content have changed. Then a {@link CollectionEvent} with + * refresh typed will be dispatched.

    + * + * @param it An iterator targeting the content changed element. + */ + refresh(it: std.Iterator): void; + /** + *

    Dispatch a {@link CollectionEvent} with refresh typed.

    + * + *

    {@link ICollection} dispatches {@link CollectionEvent} typed insert or erase whenever + * elements I/O has occured. However, unlike those elements I/O events, content change in element level can't be + * detected. There's no way to detect those events automatically by {@link IContainer}.

    + * + *

    If you want to dispatch those typed events (notifying change on contents in element level), you've to + * dispatch refresh typed event manually, by yourself. Call {@link refresh refresh()} with specified + * iterators who're pointing the elements whose content have changed. Then a {@link CollectionEvent} with + * refresh typed will be dispatched.

    + * + * @param first An Iterator to the initial position in a sequence of the content changed elmeents. + * @param last An {@link Iterator} to the final position in a sequence of the content changed elements. The range + * used is [first, last), which contains all the elements between first and + * last, including the element pointed by first but not the element pointed by + * last. + */ + refresh(first: std.Iterator, last: std.Iterator): void; /** * @inheritdoc */ addEventListener(type: string, listener: EventListener): void; + addEventListener(type: "insert", listener: CollectionEventListener): void; + addEventListener(type: "erase", listener: CollectionEventListener): void; + addEventListener(type: "refresh", listener: CollectionEventListener): void; /** * @inheritdoc */ addEventListener(type: string, listener: EventListener, thisArg: Object): void; - /** - *

    Registers an event listener object with an EventDispatcher object so that the listener - * receives notification of an event. You can register event listeners on all nodes in the display - * list for a specific type of event, phase, and priority. - * - *

    After you successfully register an event listener, you cannot change its priority through - * additional calls to addEventListener(). To change a listener's priority, you must first call - * removeEventListener(). Then you can register the listener again with the new priority level.

    - * - *

    Keep in mind that after the listener is registered, subsequent calls to addEventListener() - * with a different type or useCapture value result in the creation of a separate listener - * registration. For example, if you first register a listener with useCapture set to true, - * it listens only during the capture phase. If you call addEventListener() again using the same - * listener object, but with useCapture set to false, you have two separate listeners: one that - * listens during the capture phase and another that listens during the target and bubbling phases.

    - * - *

    You cannot register an event listener for only the target phase or the bubbling phase. - * Those phases are coupled during registration because bubbling applies only to the ancestors of - * the target node.

    - * - *

    If you no longer need an event listener, remove it by calling removeEventListener(), or - * memory problems could result. Event listeners are not automatically removed from memory because - * the garbage collector does not remove the listener as long as the dispatching object exists - * (unless the useWeakReference parameter is set to true).

    - * - *

    Copying an EventDispatcher instance does not copy the event listeners attached to it. (If - * your newly created node needs an event listener, you must attach the listener after creating - * the node.) However, if you move an EventDispatcher instance, the event listeners attached to - * it move along with it.

    - * - *

    If the event listener is being registered on a node while an event is also being processed - * on this node, the event listener is not triggered during the current phase but may be triggered - * during a later phase in the event flow, such as the bubbling phase.

    - * - *

    If an event listener is removed from a node while an event is being processed on the node, - * it is still triggered by the current actions. After it is removed, the event listener is never - * invoked again (unless it is registered again for future processing).

    - * - * @param event The type of event; {@link CollectionEvent.INSERT} or {@link CollectionEvent.ERASE}. - * @param listener The listener function that processes the event. - * This function must accept an Event object as its only parameter and must return - * nothing. - */ - addEventListener(type: "insert" | "erase", listener: CollectionEventListener): void; - /** - *

    Registers an event listener object with an EventDispatcher object so that the listener - * receives notification of an event. You can register event listeners on all nodes in the display - * list for a specific type of event, phase, and priority. - * - *

    After you successfully register an event listener, you cannot change its priority through - * additional calls to addEventListener(). To change a listener's priority, you must first call - * removeEventListener(). Then you can register the listener again with the new priority level.

    - * - *

    Keep in mind that after the listener is registered, subsequent calls to addEventListener() - * with a different type or useCapture value result in the creation of a separate listener - * registration. For example, if you first register a listener with useCapture set to true, - * it listens only during the capture phase. If you call addEventListener() again using the same - * listener object, but with useCapture set to false, you have two separate listeners: one that - * listens during the capture phase and another that listens during the target and bubbling phases.

    - * - *

    You cannot register an event listener for only the target phase or the bubbling phase. - * Those phases are coupled during registration because bubbling applies only to the ancestors of - * the target node.

    - * - *

    If you no longer need an event listener, remove it by calling removeEventListener(), or - * memory problems could result. Event listeners are not automatically removed from memory because - * the garbage collector does not remove the listener as long as the dispatching object exists - * (unless the useWeakReference parameter is set to true).

    - * - *

    Copying an EventDispatcher instance does not copy the event listeners attached to it. (If - * your newly created node needs an event listener, you must attach the listener after creating - * the node.) However, if you move an EventDispatcher instance, the event listeners attached to - * it move along with it.

    - * - *

    If the event listener is being registered on a node while an event is also being processed - * on this node, the event listener is not triggered during the current phase but may be triggered - * during a later phase in the event flow, such as the bubbling phase.

    - * - *

    If an event listener is removed from a node while an event is being processed on the node, - * it is still triggered by the current actions. After it is removed, the event listener is never - * invoked again (unless it is registered again for future processing).

    - * - * @param event The type of event; {@link CollectionEvent.INSERT} or {@link CollectionEvent.ERASE}. - * @param listener The listener function that processes the event. - * This function must accept an Event object as its only parameter and must return - * nothing. - */ - addEventListener(type: "insert" | "erase", listener: CollectionEventListener, thisArg: Object): void; + addEventListener(type: "insert", listener: CollectionEventListener, thisArg: Object): void; + addEventListener(type: "erase", listener: CollectionEventListener, thisArg: Object): void; + addEventListener(type: "refresh", listener: CollectionEventListener, thisArg: Object): void; /** * @inheritdoc */ removeEventListener(type: string, listener: EventListener): void; + removeEventListener(type: "insert", listener: CollectionEventListener): void; + removeEventListener(type: "erase", listener: CollectionEventListener): void; + removeEventListener(type: "refresh", listener: CollectionEventListener): void; /** * @inheritdoc */ removeEventListener(type: string, listener: EventListener, thisArg: Object): void; - /** - * Removes a listener from the EventDispatcher object. If there is no matching listener registered - * with the EventDispatcher object, a call to this method has no effect. - * - * @param type The type of event; {@link CollectionEvent.INSERT} or {@link CollectionEvent.ERASE}. - * @param listener The listener object to remove. - */ - removeEventListener(type: "insert" | "erase", listener: CollectionEventListener): void; - /** - * Removes a listener from the EventDispatcher object. If there is no matching listener registered - * with the EventDispatcher object, a call to this method has no effect. - * - * @param type The type of event; {@link CollectionEvent.INSERT} or {@link CollectionEvent.ERASE}. - * @param listener The listener object to remove. - */ - removeEventListener(type: "insert" | "erase", listener: CollectionEventListener, thisArg: Object): void; + removeEventListener(type: "insert", listener: CollectionEventListener, thisArg: Object): void; + removeEventListener(type: "erase", listener: CollectionEventListener, thisArg: Object): void; + removeEventListener(type: "refresh", listener: CollectionEventListener, thisArg: Object): void; } } declare namespace samchon.collection { /** * A {@link List} who can detect element I/O events. * + *
      + *
    • insert typed events:
        + *
      • {@link assign}
      • + *
      • {@link insert}
      • + *
      • {@link push}
      • + *
      • {@link push_front}
      • + *
      • {@link push_back}
      • + *
      • {@link merge}
      • + *
    • + *
    • erase typed events:
        + *
      • {@link assign}
      • + *
      • {@link clear}
      • + *
      • {@link erase}
      • + *
      • {@link pop_front}
      • + *
      • {@link pop_back}
      • + *
      • {@link unique}
      • + *
      • {@link remove}
      • + *
      • {@link remove_if}
      • + *
      • {@link splice}
      • + *
    • + *
    • erase typed events:
        + *
      • {@link sort}
      • + *
    • + *
    + * * @author Jeongho Nam */ class ListCollection extends std.List implements ICollection { @@ -772,47 +941,75 @@ declare namespace samchon.collection { * @inheritdoc */ dispatchEvent(event: Event): boolean; + /** + * @inheritdoc + */ + refresh(): void; + /** + * @inheritdoc + */ + refresh(it: std.ListIterator): void; + /** + * @inheritdoc + */ + refresh(first: std.ListIterator, last: std.ListIterator): void; /** * @inheritdoc */ addEventListener(type: string, listener: EventListener): void; + addEventListener(type: "insert", listener: CollectionEventListener): void; + addEventListener(type: "erase", listener: CollectionEventListener): void; + addEventListener(type: "refresh", listener: CollectionEventListener): void; /** * @inheritdoc */ addEventListener(type: string, listener: EventListener, thisArg: Object): void; - /** - * @inheritdoc - */ - addEventListener(type: "insert" | "erase", listener: CollectionEventListener): void; - /** - * @inheritdoc - */ - addEventListener(type: "insert" | "erase", listener: CollectionEventListener, thisArg: Object): void; + addEventListener(type: "insert", listener: CollectionEventListener, thisArg: Object): void; + addEventListener(type: "erase", listener: CollectionEventListener, thisArg: Object): void; + addEventListener(type: "refresh", listener: CollectionEventListener, thisArg: Object): void; /** * @inheritdoc */ removeEventListener(type: string, listener: EventListener): void; + removeEventListener(type: "insert", listener: CollectionEventListener): void; + removeEventListener(type: "erase", listener: CollectionEventListener): void; + removeEventListener(type: "refresh", listener: CollectionEventListener): void; /** * @inheritdoc */ removeEventListener(type: string, listener: EventListener, thisArg: Object): void; - /** - * @inheritdoc - */ - removeEventListener(type: "insert" | "erase", listener: CollectionEventListener): void; - /** - * @inheritdoc - */ - removeEventListener(type: "insert" | "erase", listener: CollectionEventListener, thisArg: Object): void; + removeEventListener(type: "insert", listener: CollectionEventListener, thisArg: Object): void; + removeEventListener(type: "erase", listener: CollectionEventListener, thisArg: Object): void; + removeEventListener(type: "refresh", listener: CollectionEventListener, thisArg: Object): void; } } declare namespace samchon.collection { /** * A {@link TreeMap} who can detect element I/O events. * + *
      + *
    • insert typed events:
        + *
      • {@link assign}
      • + *
      • {@link insert}
      • + *
      • {@link push}
      • + *
      • {@link set}
      • + *
      • {@link insert_or_assign}
      • + *
    • + *
    • erase typed events:
        + *
      • {@link assign}
      • + *
      • {@link clear}
      • + *
      • {@link erase}
      • + *
      • {@link extract}
      • + *
    • + *
    • refresh typed events:
        + *
      • {@link set}
      • + *
      • {@link insert_or_assign}
      • + *
    • + *
    + * * @author Jeongho Nam */ - class TreeMapCollection extends std.HashMap implements ICollection> { + class TreeMapCollection extends std.TreeMap implements ICollection> { /** * A chain object taking responsibility of dispatching events. */ @@ -833,45 +1030,68 @@ declare namespace samchon.collection { * @inheritdoc */ dispatchEvent(event: Event): boolean; + /** + * @inheritdoc + */ + refresh(): void; + /** + * @inheritdoc + */ + refresh(it: std.MapIterator): void; + /** + * @inheritdoc + */ + refresh(first: std.MapIterator, last: std.MapIterator): void; /** * @inheritdoc */ addEventListener(type: string, listener: EventListener): void; + addEventListener(type: "insert", listener: CollectionEventListener>): void; + addEventListener(type: "erase", listener: CollectionEventListener>): void; + addEventListener(type: "refresh", listener: CollectionEventListener>): void; /** * @inheritdoc */ addEventListener(type: string, listener: EventListener, thisArg: Object): void; - /** - * @inheritdoc - */ - addEventListener(type: "insert" | "erase", listener: CollectionEventListener): void; - /** - * @inheritdoc - */ - addEventListener(type: "insert" | "erase", listener: CollectionEventListener, thisArg: Object): void; + addEventListener(type: "insert", listener: CollectionEventListener>, thisArg: Object): void; + addEventListener(type: "erase", listener: CollectionEventListener>, thisArg: Object): void; + addEventListener(type: "refresh", listener: CollectionEventListener>, thisArg: Object): void; /** * @inheritdoc */ removeEventListener(type: string, listener: EventListener): void; + removeEventListener(type: "insert", listener: CollectionEventListener>): void; + removeEventListener(type: "erase", listener: CollectionEventListener>): void; + removeEventListener(type: "refresh", listener: CollectionEventListener>): void; /** * @inheritdoc */ removeEventListener(type: string, listener: EventListener, thisArg: Object): void; - /** - * @inheritdoc - */ - removeEventListener(type: "insert" | "erase", listener: CollectionEventListener): void; - /** - * @inheritdoc - */ - removeEventListener(type: "insert" | "erase", listener: CollectionEventListener, thisArg: Object): void; + removeEventListener(type: "insert", listener: CollectionEventListener>, thisArg: Object): void; + removeEventListener(type: "erase", listener: CollectionEventListener>, thisArg: Object): void; + removeEventListener(type: "refresh", listener: CollectionEventListener>, thisArg: Object): void; } +} +declare namespace samchon.collection { /** * A {@link TreeMultiMap} who can detect element I/O events. * + *
      + *
    • insert typed events:
        + *
      • {@link assign}
      • + *
      • {@link insert}
      • + *
      • {@link push}
      • + *
    • + *
    • erase typed events:
        + *
      • {@link assign}
      • + *
      • {@link clear}
      • + *
      • {@link erase}
      • + *
    • + *
    + * * @author Jeongho Nam */ - class TreeMultiMapCollection extends std.HashMap implements ICollection> { + class TreeMultiMapCollection extends std.TreeMultiMap implements ICollection> { /** * A chain object taking responsibility of dispatching events. */ @@ -892,95 +1112,65 @@ declare namespace samchon.collection { * @inheritdoc */ dispatchEvent(event: Event): boolean; + /** + * @inheritdoc + */ + refresh(): void; + /** + * @inheritdoc + */ + refresh(it: std.MapIterator): void; + /** + * @inheritdoc + */ + refresh(first: std.MapIterator, last: std.MapIterator): void; /** * @inheritdoc */ addEventListener(type: string, listener: EventListener): void; + addEventListener(type: "insert", listener: CollectionEventListener>): void; + addEventListener(type: "erase", listener: CollectionEventListener>): void; + addEventListener(type: "refresh", listener: CollectionEventListener>): void; /** * @inheritdoc */ addEventListener(type: string, listener: EventListener, thisArg: Object): void; - /** - * @inheritdoc - */ - addEventListener(type: "insert" | "erase", listener: CollectionEventListener): void; - /** - * @inheritdoc - */ - addEventListener(type: "insert" | "erase", listener: CollectionEventListener, thisArg: Object): void; + addEventListener(type: "insert", listener: CollectionEventListener>, thisArg: Object): void; + addEventListener(type: "erase", listener: CollectionEventListener>, thisArg: Object): void; + addEventListener(type: "refresh", listener: CollectionEventListener>, thisArg: Object): void; /** * @inheritdoc */ removeEventListener(type: string, listener: EventListener): void; + removeEventListener(type: "insert", listener: CollectionEventListener>): void; + removeEventListener(type: "erase", listener: CollectionEventListener>): void; + removeEventListener(type: "refresh", listener: CollectionEventListener>): void; /** * @inheritdoc */ removeEventListener(type: string, listener: EventListener, thisArg: Object): void; - /** - * @inheritdoc - */ - removeEventListener(type: "insert" | "erase", listener: CollectionEventListener): void; - /** - * @inheritdoc - */ - removeEventListener(type: "insert" | "erase", listener: CollectionEventListener, thisArg: Object): void; + removeEventListener(type: "insert", listener: CollectionEventListener>, thisArg: Object): void; + removeEventListener(type: "erase", listener: CollectionEventListener>, thisArg: Object): void; + removeEventListener(type: "refresh", listener: CollectionEventListener>, thisArg: Object): void; } } declare namespace samchon.collection { - /** - * A {@link TreeMap} who can detect element I/O events. - * - * @author Jeongho Nam - */ - class TreeSetCollection extends std.TreeSet implements ICollection { - /** - * A chain object taking responsibility of dispatching events. - */ - private event_dispatcher_; - /** - * @inheritdoc - */ - hasEventListener(type: string): boolean; - /** - * @inheritdoc - */ - dispatchEvent(event: Event): boolean; - /** - * @inheritdoc - */ - addEventListener(type: string, listener: EventListener): void; - /** - * @inheritdoc - */ - addEventListener(type: string, listener: EventListener, thisArg: Object): void; - /** - * @inheritdoc - */ - addEventListener(type: "insert" | "erase", listener: CollectionEventListener): void; - /** - * @inheritdoc - */ - addEventListener(type: "insert" | "erase", listener: CollectionEventListener, thisArg: Object): void; - /** - * @inheritdoc - */ - removeEventListener(type: string, listener: EventListener): void; - /** - * @inheritdoc - */ - removeEventListener(type: string, listener: EventListener, thisArg: Object): void; - /** - * @inheritdoc - */ - removeEventListener(type: "insert" | "erase", listener: CollectionEventListener): void; - /** - * @inheritdoc - */ - removeEventListener(type: "insert" | "erase", listener: CollectionEventListener, thisArg: Object): void; - } /** * A {@link TreeMultiSet} who can detect element I/O events. * + *
      + *
    • insert typed events:
        + *
      • {@link assign}
      • + *
      • {@link insert}
      • + *
      • {@link push}
      • + *
    • + *
    • erase typed events:
        + *
      • {@link assign}
      • + *
      • {@link clear}
      • + *
      • {@link erase}
      • + *
    • + *
    + * * @author Jeongho Nam */ class TreeMultiSetCollection extends std.TreeMultiSet implements ICollection { @@ -1004,38 +1194,121 @@ declare namespace samchon.collection { * @inheritdoc */ dispatchEvent(event: Event): boolean; + /** + * @inheritdoc + */ + refresh(): void; + /** + * @inheritdoc + */ + refresh(it: std.SetIterator): void; + /** + * @inheritdoc + */ + refresh(first: std.SetIterator, last: std.SetIterator): void; /** * @inheritdoc */ addEventListener(type: string, listener: EventListener): void; + addEventListener(type: "insert", listener: CollectionEventListener): void; + addEventListener(type: "erase", listener: CollectionEventListener): void; + addEventListener(type: "refresh", listener: CollectionEventListener): void; /** * @inheritdoc */ addEventListener(type: string, listener: EventListener, thisArg: Object): void; - /** - * @inheritdoc - */ - addEventListener(type: "insert" | "erase", listener: CollectionEventListener): void; - /** - * @inheritdoc - */ - addEventListener(type: "insert" | "erase", listener: CollectionEventListener, thisArg: Object): void; + addEventListener(type: "insert", listener: CollectionEventListener, thisArg: Object): void; + addEventListener(type: "erase", listener: CollectionEventListener, thisArg: Object): void; + addEventListener(type: "refresh", listener: CollectionEventListener, thisArg: Object): void; /** * @inheritdoc */ removeEventListener(type: string, listener: EventListener): void; + removeEventListener(type: "insert", listener: CollectionEventListener): void; + removeEventListener(type: "erase", listener: CollectionEventListener): void; + removeEventListener(type: "refresh", listener: CollectionEventListener): void; /** * @inheritdoc */ removeEventListener(type: string, listener: EventListener, thisArg: Object): void; + removeEventListener(type: "insert", listener: CollectionEventListener, thisArg: Object): void; + removeEventListener(type: "erase", listener: CollectionEventListener, thisArg: Object): void; + removeEventListener(type: "refresh", listener: CollectionEventListener, thisArg: Object): void; + } +} +declare namespace samchon.collection { + /** + * A {@link TreeMap} who can detect element I/O events. + * + *
      + *
    • insert typed events:
        + *
      • {@link assign}
      • + *
      • {@link insert}
      • + *
      • {@link push}
      • + *
    • + *
    • erase typed events:
        + *
      • {@link assign}
      • + *
      • {@link clear}
      • + *
      • {@link erase}
      • + *
      • {@link extract}
      • + *
    • + *
    + * + * @author Jeongho Nam + */ + class TreeSetCollection extends std.TreeSet implements ICollection { + /** + * A chain object taking responsibility of dispatching events. + */ + private event_dispatcher_; /** * @inheritdoc */ - removeEventListener(type: "insert" | "erase", listener: CollectionEventListener): void; + hasEventListener(type: string): boolean; /** * @inheritdoc */ - removeEventListener(type: "insert" | "erase", listener: CollectionEventListener, thisArg: Object): void; + dispatchEvent(event: Event): boolean; + /** + * @inheritdoc + */ + refresh(): void; + /** + * @inheritdoc + */ + refresh(it: std.SetIterator): void; + /** + * @inheritdoc + */ + refresh(first: std.SetIterator, last: std.SetIterator): void; + /** + * @inheritdoc + */ + addEventListener(type: string, listener: EventListener): void; + addEventListener(type: "insert", listener: CollectionEventListener): void; + addEventListener(type: "erase", listener: CollectionEventListener): void; + addEventListener(type: "refresh", listener: CollectionEventListener): void; + /** + * @inheritdoc + */ + addEventListener(type: string, listener: EventListener, thisArg: Object): void; + addEventListener(type: "insert", listener: CollectionEventListener, thisArg: Object): void; + addEventListener(type: "erase", listener: CollectionEventListener, thisArg: Object): void; + addEventListener(type: "refresh", listener: CollectionEventListener, thisArg: Object): void; + /** + * @inheritdoc + */ + removeEventListener(type: string, listener: EventListener): void; + removeEventListener(type: "insert", listener: CollectionEventListener): void; + removeEventListener(type: "erase", listener: CollectionEventListener): void; + removeEventListener(type: "refresh", listener: CollectionEventListener): void; + /** + * @inheritdoc + */ + removeEventListener(type: string, listener: EventListener, thisArg: Object): void; + removeEventListener(type: "insert", listener: CollectionEventListener, thisArg: Object): void; + removeEventListener(type: "erase", listener: CollectionEventListener, thisArg: Object): void; + removeEventListener(type: "refresh", listener: CollectionEventListener, thisArg: Object): void; } } declare namespace samchon.library { @@ -1373,7 +1646,7 @@ declare namespace samchon.library { * * @author Jeongho Nam */ - class XMLList extends std.Vector { + class XMLList extends std.Deque { getTag(): string; /** *

    Convert XMLList to string.

    @@ -1390,6 +1663,30 @@ declare namespace samchon.library { } } declare namespace samchon.collection { + /** + * An {@link XMLList} who can detect element I/O events. + * + *

    Below are list of methods who are dispatching {@link CollectionEvent}:

    + * + *
      + *
    • insert typed events:
        + *
      • {@link assign}
      • + *
      • {@link insert}
      • + *
      • {@link push}
      • + *
      • {@link push_front}
      • + *
      • {@link push_back}
      • + *
    • + *
    • erase typed events:
        + *
      • {@link assign}
      • + *
      • {@link clear}
      • + *
      • {@link erase}
      • + *
      • {@link pop_front}
      • + *
      • {@link pop_back}
      • + *
    • + *
    + * + * @author Jeongho Nam + */ class XMLListCollection extends library.XMLList implements ICollection { /** * A chain object taking responsibility of dispatching events. @@ -1406,11 +1703,11 @@ declare namespace samchon.collection { /** * @hidden */ - protected insert_by_repeating_val(position: std.VectorIterator, n: number, val: library.XML): std.VectorIterator; + protected insert_by_repeating_val(position: std.DequeIterator, n: number, val: library.XML): std.DequeIterator; /** * @hidden */ - protected insert_by_range>(position: std.VectorIterator, begin: InputIterator, end: InputIterator): std.VectorIterator; + protected insert_by_range>(position: std.DequeIterator, begin: InputIterator, end: InputIterator): std.DequeIterator; /** * @inheritdoc */ @@ -1418,7 +1715,7 @@ declare namespace samchon.collection { /** * @hidden */ - protected erase_by_range(first: std.VectorIterator, last: std.VectorIterator): std.VectorIterator; + protected erase_by_range(first: std.DequeIterator, last: std.DequeIterator): std.DequeIterator; /** * @hidden */ @@ -1435,71 +1732,57 @@ declare namespace samchon.collection { * @inheritdoc */ dispatchEvent(event: Event): boolean; + /** + * @inheritdoc + */ + refresh(): void; + /** + * @inheritdoc + */ + refresh(it: std.DequeIterator): void; + /** + * @inheritdoc + */ + refresh(first: std.DequeIterator, last: std.DequeIterator): void; /** * @inheritdoc */ addEventListener(type: string, listener: EventListener): void; + addEventListener(type: "insert", listener: CollectionEventListener): void; + addEventListener(type: "erase", listener: CollectionEventListener): void; + addEventListener(type: "refresh", listener: CollectionEventListener): void; /** * @inheritdoc */ addEventListener(type: string, listener: EventListener, thisArg: Object): void; - /** - * @inheritdoc - */ - addEventListener(type: "insert" | "erase", listener: CollectionEventListener): void; - /** - * @inheritdoc - */ - addEventListener(type: "insert" | "erase", listener: CollectionEventListener, thisArg: Object): void; + addEventListener(type: "insert", listener: CollectionEventListener, thisArg: Object): void; + addEventListener(type: "erase", listener: CollectionEventListener, thisArg: Object): void; + addEventListener(type: "refresh", listener: CollectionEventListener, thisArg: Object): void; /** * @inheritdoc */ removeEventListener(type: string, listener: EventListener): void; + removeEventListener(type: "insert", listener: CollectionEventListener): void; + removeEventListener(type: "erase", listener: CollectionEventListener): void; + removeEventListener(type: "refresh", listener: CollectionEventListener): void; /** * @inheritdoc */ removeEventListener(type: string, listener: EventListener, thisArg: Object): void; - /** - * @inheritdoc - */ - removeEventListener(type: "insert" | "erase", listener: CollectionEventListener): void; - /** - * @inheritdoc - */ - removeEventListener(type: "insert" | "erase", listener: CollectionEventListener, thisArg: Object): void; - /** - * @inheritdoc - */ - unshift(...items: U[]): number; - /** - * @inheritdoc - */ - pop(): library.XML; - /** - * @inheritdoc - */ - splice(start: number): library.XML[]; - /** - * @inheritdoc - */ - splice(start: number, deleteCount: number, ...items: library.XML[]): library.XML[]; + removeEventListener(type: "insert", listener: CollectionEventListener, thisArg: Object): void; + removeEventListener(type: "erase", listener: CollectionEventListener, thisArg: Object): void; + removeEventListener(type: "refresh", listener: CollectionEventListener, thisArg: Object): void; } } -declare namespace samchon.example { - function test_file_reference(): void; -} -declare namespace samchon.example { - function test_web_client(): void; -} declare namespace samchon.library { /** *

    Case generator.

    * - *

    CaseGenerator is an abstract case generator using like a matrix.

    + *

    {@link CaseGenerator} is an abstract case generator being used like a matrix.

    *
      - *
    • nTTr(n^r) -> CombinedPermutationGenerator
    • - *
    • nPr -> PermutationGenerator
    • - *
    • n! -> FactorialGenerator
    • + *
    • n��r(n^r) -> {@link CombinedPermutationGenerator}
    • + *
    • nPr -> {@link PermutationGenerator}
    • + *
    • n! -> {@link FactorialGenerator}
    • *
    * * @author Jeongho Nam @@ -1544,13 +1827,13 @@ declare namespace samchon.library { * @param index Index number * @return The row of the index'th in combined permuation case */ - abstract at(index: number): Array; + abstract at(index: number): number[]; } /** *

    A combined-permutation case generator.

    - *

    nTTr

    * - * @inheritdoc + *

    n��r

    + * * @author Jeongho Nam */ class CombinedPermutationGenerator extends CaseGenerator { @@ -1565,14 +1848,14 @@ declare namespace samchon.library { * @param r Size of elements of each case. */ constructor(n: number, r: number); - at(index: number): Array; + at(index: number): number[]; } /** *

    A permutation case generator.

    - *

    nPr

    + * + *

    nPr

    * * @author Jeongho Nam - * @inheritdoc */ class PermuationGenerator extends CaseGenerator { /** @@ -1585,8 +1868,15 @@ declare namespace samchon.library { /** * @inheritdoc */ - at(index: number): Array; + at(index: number): number[]; } + /** + *

    Factorial case generator.

    + * + *

    n! = nPn

    + * + * @author Jeongho Nam + */ class FactorialGenerator extends PermuationGenerator { /** * Construct from factorial size N. @@ -1602,8 +1892,8 @@ declare namespace samchon.library { * whether specific types of event listeners are registered, and dispatches events.

    * *

    Event targets are an important part of the Flash�� Player and Adobe AIR event model. The event - * target serves as the focal point for how events flow through the display list hierarchy. When an - * event such as a mouse click or a keypress occurs, an event object is dispatched into the event flow + * target serves as the local point for how events flow through the display list hierarchy. When an + * event such as a mouse click or a key press occurs, an event object is dispatched into the event flow * from the root of the display list. The event object makes a round-trip journey to the event target, * which is conceptually divided into three phases: the capture phase includes the journey from the * root to the last node before the event target's node; the target phase includes only the event @@ -1728,6 +2018,7 @@ declare namespace samchon.library { * @param listener The listener function that processes the event. * This function must accept an Event object as its only parameter and must return * nothing. + * @param thisArg The object to be used as the this object. */ addEventListener(type: string, listener: EventListener, thisArg: Object): void; /** @@ -1744,6 +2035,7 @@ declare namespace samchon.library { * * @param type The type of event. * @param listener The listener object to remove. + * @param thisArg The object to be used as the this object. */ removeEventListener(type: string, listener: EventListener, thisArg: Object): void; } @@ -1795,11 +2087,11 @@ declare namespace samchon.library { /** * The origin object who issuing events. */ - protected target: IEventDispatcher; + protected event_dispatcher_: IEventDispatcher; /** * Container of listeners. */ - protected listeners: std.HashMap>>; + protected event_listeners_: std.HashMap>>; /** * Default Constructor. */ @@ -1807,9 +2099,9 @@ declare namespace samchon.library { /** * Construct from the origin event dispatcher. * - * @param target The origin object who issuing events. + * @param dispatcher The origin object who issuing events. */ - constructor(target: IEventDispatcher); + constructor(dispatcher: IEventDispatcher); /** * @inheritdoc */ @@ -2011,6 +2303,31 @@ declare namespace samchon.library { * @param fileName File name to be saved. */ save(data: string, fileName: string): void; + /** + *

    Save a file to local filesystem.

    + * + *

    {@link FileReference.save} implemented the save function by downloading a file from a hidden anchor tag. + * However, the plan, future's {@link FileReference} will follow such rule:

    + * + *

    Opens a dialog box that lets the user save a file to the local filesystem.

    + * + *

    The {@link save save()} method first opens an browser-system dialog box that asks the user to enter a + * filename and select a location on the local computer to save the file. When the user selects a location and + * confirms the save operation (for example, by clicking Save), the save process begins. Listeners receive events + * to indicate the progress, success, or failure of the save operation. To ascertain the status of the dialog box + * and the save operation after calling {@link save save()}, your code must listen for events such as cancel, + * open, progress, and complete.

    + * + *

    When the file is saved successfully, the properties of the {@link FileReference} object are populated with + * the properties of the local file. The complete event is dispatched if the save is successful.

    + * + *

    Only one {@link browse browse()} or {@link save()} session can be performed at a time (because only one + * dialog box can be invoked at a time).

    + * + * @param data The data to be saved. The data can be in one of several formats, and will be treated appropriately. + * @param fileName File name to be saved. + */ + static save(data: string, fileName: string): void; } /** *

    The {@link FileReferenceList} class provides a means to let users select one or more files for @@ -2081,10 +2398,251 @@ declare namespace samchon.library { browse(...typeFilter: string[]): void; } } +declare namespace samchon.library { + /** + *

    A genetic algorithm class.

    + * + * @details + *

    In the field of artificial intelligence, a genetic algorithm (GA) is a search heuristic that mimics the + * process of natural selection. This heuristic (also sometimes called a metaheuristic) is routinely used to generate + * useful solutions to optimization and search problems.

    + * + *

    Genetic algorithms belong to the larger class of evolutionary algorithms (EA), which generate solutions to + * optimization problems using techniques inspired by natural evolution, such as inheritance, {@link mutate mutation}, + * {@link selection}, and {@link crossover}.

    + * + * @reference https://en.wikipedia.org/wiki/Genetic_algorithm + * @author Jeongho Nam + */ + class GeneticAlgorithm { + /** + * Whether each element (Gene) is unique in their GeneArray. + */ + private unique; + /** + * Rate of mutation. + * + * The {@link mutation_rate} determines the percentage of occurence of mutation in GeneArray. + * + *
      + *
    • When {@link mutation_rate} is too high, it is hard to ancitipate studying on genetic algorithm.
    • + *
    • + * When {@link mutation_rate} is too low and initial set of genes (GeneArray) is far away from optimal, the + * evolution tends to wandering outside of he optimal. + *
    • + *
    + */ + private mutation_rate; + /** + * Number of tournaments in selection. + */ + private tournament; + /** + * Initialization Constructor. + * + * @param unique Whether each Gene is unique in their GeneArray. + * @param mutation_rate Rate of mutation. + * @param tournament Number of tournaments in selection. + */ + constructor(unique?: boolean, mutation_rate?: number, tournament?: number); + /** + *

    Evolove GeneArray.

    + * + *

    Convenient method accessing to {@link evolvePopulation evolvePopulation()}.

    + * + * @param individual An initial set of genes; sequence listing. + * @param population Size of population in a generation. + * @param generation Size of generation in evolution. + * @param compare A comparison function returns whether left gene is more optimal. + * + * @return An evolved GeneArray, optimally. + * + * @see {@link GAPopulation.compare} + */ + evolveGeneArray>(individual: GeneArray, population: number, generation: number, compare?: (left: T, right: T) => boolean): GeneArray; + /** + * Evolve population, a mass of GeneArraies. + * + * @param population An initial population. + * @param compare A comparison function returns whether left gene is more optimal. + * + * @return An evolved population. + * + * @see {@link GAPopulation.compare} + */ + evolvePopulation>(population: GAPopulation, compare?: (left: T, right: T) => boolean): GAPopulation; + /** + *

    Select the best GeneArray in population from tournament.

    + * + *

    {@link selection Selection} is the stage of a genetic algorithm in which individual genomes are chosen + * from a population for later breeding (using {@linlk crossover} operator). A generic {@link selection} + * procedure may be implemented as follows:

    + * + *
      + *
    1. + * The fitness function is evaluated for each individual, providing fitness values, which are then + * normalized. ization means dividing the fitness value of each individual by the sum of all fitness + * values, so that the sum of all resulting fitness values equals 1. + *
    2. + *
    3. The population is sorted by descending fitness values.
    4. + *
    5. + * Accumulated normalized fitness values are computed (the accumulated fitness value of an individual is the + * sum of its own fitness value plus the fitness values of all the previous individuals). The accumulated + * fitness of the last individual should be 1 (otherwise something went wrong in the normalization step). + *
    6. + *
    7. A random number R between 0 and 1 is chosen.
    8. + *
    9. The selected individual is the first one whose accumulated normalized value is greater than R.
    10. + *
    + * + * @param population The target of tournament. + * @return The best genes derived by the tournament. + * + * @reference https://en.wikipedia.org/wiki/Selection_(genetic_algorithm) + */ + private selection(population); + /** + *

    Create a new GeneArray by crossing over two GeneArray(s).

    + * + *

    {@link crossover} is a genetic operator used to vary the programming of a chromosome or chromosomes from + * one generation to the next. It is analogous to reproduction and biological crossover, upon which genetic + * algorithms are based.

    + * + *

    {@link crossover Cross over} is a process of taking more than one parent solutions and producing a child + * solution from them. There are methods for selection of the chromosomes.

    + * + * @param parent1 A parent sequence listing + * @param parent2 A parent sequence listing + * + * @reference https://en.wikipedia.org/wiki/Crossover_(genetic_algorithm) + */ + private crossover(parent1, parent2); + /** + *

    Cause a mutation on the GeneArray.

    + * + *

    {@link mutate Mutation} is a genetic operator used to maintain genetic diversity from one generation of a + * population of genetic algorithm chromosomes to the next. It is analogous to biological mutation.

    + * + *

    {@link mutate Mutation} alters one or more gene values in a chromosome from its initial state. In + * {@link mutate mutation}, the solution may change entirely from the previous solution. Hence GA can come to + * better solution by using {@link mutate mutation}.

    + * + *

    {@link mutate Mutation} occurs during evolution according to a user-definable mutation probability. This + * probability should be set low. If it is set too high, the search will turn into a primitive random search.

    + * + *

    Note

    + *

    Muttion is pursuing diversity. Mutation is useful for avoiding the following problem.

    + * + *

    When initial set of genes(GeneArray) is far away from optimail, without mutation (only with selection and + * crossover), the genetic algorithm has a tend to wandering outside of the optimal.

    + * + *

    Genes in the GeneArray will be swapped following percentage of the {@link mutation_rate}.

    + * + * @param individual A container of genes to mutate + * + * @reference https://en.wikipedia.org/wiki/Mutation_(genetic_algorithm) + * @see {@link mutation_rate} + */ + private mutate(individual); + } + /** + *

    A population in a generation.

    + * + *

    {@link GAPopulation} is a class representing population of candidate genes (sequence listing) having an array + * of GeneArray as a member. {@link GAPopulation} also manages initial set of genes and handles fitting test direclty + * by the method {@link fitTest fitTest()}.

    + * + *

    The success of evolution of genetic algorithm is depend on the {@link GAPopulation}'s initial set and fitting + * test. (GeneArray and {@link compare}.)

    + * + *

    Warning

    + *

    Be careful for the mistakes of direction or position of the {@link compare}.

    + *

    Most of logical errors failed to access optimal solution are occured from those mistakes.

    + * + * @param Type of gene elements. + * @param An array containing genes as elments; sequnce listing. + * + * @author Jeongho Nam + */ + class GAPopulation> { + /** + * Genes representing the population. + */ + private children; + /** + *

    A comparison function returns whether left gene is more optimal, greater.

    + * + *

    Default value of this {@link compare} is {@link std.greater}. It means to compare two array + * (GeneArray must be a type of {@link std.base.IArrayContainer}). Thus, you've to keep follwing rule.

    + * + *
      + *
    • GeneArray is implemented from {@link std.base.IArrayContainer}.
    • + *
        + *
      • {@link std.Vector}
      • + *
      • {@link std.Deque}
      • + *
      + *
    • GeneArray has custom public less(obj: T): boolean; function.
    • + *
    + * + *

    If you don't want to follow the rule or want a custom comparison function, you have to realize a + * comparison function.

    + */ + private compare; + /** + *

    Private constructor with population.

    + * + *

    Private constructor of GAPopulation does not create {@link children}. (candidate genes) but only assigns + * null repeatedly following the population size.

    + * + *

    This private constructor is designed only for {@link GeneticAlgorithm}. Don't create {@link GAPopulation} + * with this constructor, by yourself.

    + * + * @param size Size of the population. + */ + constructor(size: number); + /** + *

    Construct from a {@link GeneArray} and size of the population.

    + * + *

    This public constructor creates GeneArray(s) as population (size) having shuffled genes which are + * came from the initial set of genes (geneArray). It uses {@link std.greater} as default comparison function. + *

    + * + * @param geneArray An initial sequence listing. + * @param size The size of population to have as children. + */ + constructor(geneArray: GeneArray, size: number); + /** + *

    Constructor from a GeneArray, size of the poluation and custom comparison function.

    + * + *

    This public constructor creates GeneArray(s) as population (size) having shuffled genes which are + * came from the initial set of genes (geneArray). The compare is used for comparison function. + *

    + * + * @param geneArray An initial sequence listing. + * @param size The size of population to have as children. + * @param compare A comparison function returns whether left gene is more optimal. + */ + constructor(geneArray: GeneArray, size: number, compare: (left: GeneArray, right: GeneArray) => boolean); + /** + * Test fitness of each GeneArray in the {@link population}. + * + * @return The best GeneArray in the {@link population}. + */ + fitTest(): GeneArray; + /** + * @hidden + */ + private clone(obj); + } +} declare namespace samchon.library { /** *

    A utility class supporting static methods of string.

    * + *

    The {@link StringUtil} utility class is an all-static class with methods for working with string objects within + * Samchon Framework. You do not create instances of {@link StringUtil}; instead you call methods such as the + * StringUtil.substitute() method.

    + * + * @reference http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/mx/utils/StringUtil.html * @author Jeongho Nam */ class StringUtil { @@ -2105,11 +2663,11 @@ declare namespace samchon.library { *
  • If start and end are all omitted, returns str, itself.
  • *
* - * @param str Target string to be applied between - * @param start A string for separating substring at the front - * @param end A string for separating substring at the end + * @param str Target string to be applied between. + * @param start A string for separating substring at the front. + * @param end A string for separating substring at the end. * - * @return substring by specified terms + * @return substring by specified terms. */ static between(str: string, start?: string, end?: string): string; /** @@ -2124,12 +2682,12 @@ declare namespace samchon.library { *
  • If startStr and endStar are all omitted, returns str.
  • * * - * @param str Target string to split by between + * @param str Target string to split by between. * @param start A string for separating substring at the front. - * If omitted, it's same with split(end) not having last item + * If omitted, it's same with split(end) not having last item. * @param end A string for separating substring at the end. - * If omitted, it's same with split(start) not having first item - * @return An array of substrings + * If omitted, it's same with split(start) not having first item. + * @return An array of substrings. */ static betweens(str: string, start?: string, end?: string): Array; /** @@ -2195,20 +2753,74 @@ declare namespace samchon.library { * @return A string specified words are replaced */ static replaceAll(str: string, ...pairs: std.Pair[]): string; - /** - *

    Get a tabbed string by specified size.

    - */ - static tab(size: number): string; - /** - *

    Get a tabbed HTLM string by specified size.

    - */ - static htmlTab(size: number): string; /** * Replace all HTML spaces to a literal space. * * @param str Target string to replace. */ static removeHTMLSpaces(str: string): string; + /** + *

    Repeat a string.

    + * + *

    Returns a string consisting of a specified string concatenated with itself a specified number of times.

    + * + * @param str The string to be repeated. + * @param n The repeat count. + * + * @return The repeated string. + */ + static repeat(str: string, n: number): string; + /** + *

    Number to formatted string with "," sign.

    + * + *

    Returns a string converted from the number rounded off from specified precision with "," symbols.

    + * + * @param val A number wants to convert to string. + * @param precision Target precision of round off. + * + * @return A string who represents the number with roundoff and "," symbols. + */ + static numberFormat(val: number, precision?: number): string; + static percentFormat(val: number, precision?: number): string; + } +} +declare namespace samchon.library { + /** + *

    URLVariables class is for representing variables of HTTP.

    + * + *

    URLVariables class allows you to transfer variables between an application and server. + * When transfering, URLVariables will be converted to a URI string.

    + * + *
      + *
    • URI: Uniform Resource Identifier
    • + *
    + * + * @reference http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/URLVariables.html + * @author Migrated by Jeongho Nam + */ + class URLVariables extends std.HashMap { + /** + * Default Constructor. + */ + constructor(); + /** + *

    Construct from a URL-encoded string.

    + * + *

    The {@link decode decode()} method is automatically called to convert the string to properties of the {@link URLVariables} object.

    + * + * @param str A URL-encoded string containing name/value pairs. + */ + constructor(str: string); + /** + * Converts the variable string to properties of the specified URLVariables object. + * + * @param str A URL-encoded query string containing name/value pairs. + */ + decode(str: string): void; + /** + * Returns a string containing all enumerable variables, in the MIME content encoding application/x-www-form-urlencoded. + */ + toString(): string; } } declare namespace samchon.protocol { @@ -2247,20 +2859,31 @@ declare namespace samchon.protocol { * * @param xml An xml used to contruct data of entity. */ - construct(xml: library.XML): any; + construct(xml: library.XML): void; /** *

    Get a key that can identify the Entity uniquely.

    * - *

    If identifier of the Entity is not atomic value, returns a string or paired object + *

    If identifier of the Entity is not atomic value, returns a paired or tuple object * that can represents the composite identifier.

    + * + * + * class Point extends Entity + * { + * private x: number; + * private y: number; + * + * public key(): std.Pair + * { + * return std.make_pair(this.x, this.y); + * } + * } + * */ key(): any; /** *

    A tag name when represented by XML.

    * - *
      - *
    • - *
    + * */ TAG(): string; /** @@ -2345,6 +2968,593 @@ declare namespace samchon.protocol { toXML(): library.XML; } } +declare namespace samchon.protocol { + /** + *

    An interface taking full charge of network communication.

    + * + *

    {@link ICommunicator} is an interface for communicator classes who take full charge of network communication + * with external system, without reference to whether the external system is a server or a client.

    + * + *

    Whenever a replied message comes from the external system, the message will be converted to an + * {@link Invoke} class and will be shifted to the {@link WebCommunicator.listener listener}'s + * {@link IProtocol.replyData replyData()} method.

    + * + * + interface ICommmunicator + { + private socket: SomeSocketClass; + + // LISTENER LISTENS INVOKE MESSAGE BY IT'S IProtocol.replyData() METHOD + protected listener: IProtocol; + + // YOU CAN DETECT DISCONNECTION BY ENROLLING FUNCTION POINTER TO HERE. + public onClose: Function; + + public sendData(invoke: Invoke): void + { + this.socket.write(invoke); + } + public replyData(invoke: Invoke): void + { + // WHENEVER COMMUNICATOR GETS MESSAGE, THEN SHIFT IT TO LISTENER'S replyData() METHOD. + this.listener.replyData(invoke); + } + } + * + * + *

    + * + *

    + * + * + *

    Basic Components

    + *

    What Basic Components are

    + *

    Basic Components are the smallest unit of network communication in this Samchon Framework. With + * Basic Components, you can construct any type of network system, even how the network system is enormously + * scaled and complicated, by just combinating the Basic Components.

    + * + *

    All the system templates in this framework are also being implemented by utilization of the + * Basic Compoonents.

    + * + *
      + *
    • {@link service Service} + *
    • {@link external External System} + *
    • {@link parallel Parallel System} + *
    • {@link distributed Distributed System} + *
    + * + *

    Note that, whatever the network system what you've to construct is, just concentrate on role of each system + * and attach matched Basic Components to the role, within framework of the Object-Oriented Design. + * Then construction of the network system will be much easier.

    + * + *
      + *
    • A system is a server, then use {@link IServer} or {@link IServerBase}.
    • + *
    • A server wants to handle a client has connected, then use {@link IClientDriver}.
    • + *
    • A system is a client connecting to an external server, then use {@link IServerConnector}.
    • + *
    • + *
    + * + *

    Example - System Templates

    + *

    Learning and understanding Basic Components of Samchon Framework, reading source codes and design of + * System Templates' modules will be very helpful.

    + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
    Name Source API Documents
    Cloud Service protocol/service {@link protocol.service}
    External System protocol/external {@link protocol.external}
    Parallel System protocol/parallel {@link protocol.parallel}
    Distributed System protocol/distributed {@link protocol.distributed}
    Slave System protocol/slave {@link protocol.slave}
    + * + *

    Example - Projects

    + * + * + * @see {@link IClientDriver}, {@link IServerConnector} + * @handbook Basic Components - ICommunicator + * @author Jeongho Nam + */ + interface ICommunicator extends IProtocol { + /** + * Callback function for connection closed. + */ + onClose: Function; + /** + * Close connection. + */ + close(): any; + sendData(invoke: protocol.Invoke): void; + replyData(invoke: protocol.Invoke): void; + } +} +declare namespace samchon.protocol { + abstract class CommunicatorBase implements ICommunicator { + /** + * @hidden + */ + protected listener: IProtocol; + /** + * @inheritdoc + */ + onClose: Function; + /** + * @hidden + */ + private binary_invoke; + /** + * @hidden + */ + private binary_parameters; + /** + * @hidden + */ + private unhandled_invokes; + /** + * Default Constructor. + */ + constructor(); + constructor(listener: IProtocol); + /** + * @inheritdoc + */ + abstract close(): void; + protected is_binary_invoke(): boolean; + abstract sendData(invoke: Invoke): void; + replyData(invoke: Invoke): void; + protected handle_string(str: string): void; + protected handle_binary(binary: Uint8Array): void; + } +} +declare namespace samchon.protocol { + class Communicator extends CommunicatorBase { + /** + * @hidden + */ + protected socket: socket.socket; + /** + * @hidden + */ + private header_bytes; + /** + * @hidden + */ + private data; + /** + * @hidden + */ + private data_index; + /** + * @hidden + */ + private listening; + /** + * @inheritdoc + */ + close(): void; + /** + * @hidden + */ + protected start_listen(): void; + /** + * @hidden + */ + private handle_error(); + /** + * @hidden + */ + private handle_close(); + /** + * @inheritdoc + */ + sendData(invoke: Invoke): void; + /** + * @hidden + */ + private listen_piece(piece); + /** + * @hidden + */ + private listen_header(piece, piece_index); + /** + * @hidden + */ + private listen_data(piece, piece_index); + } +} +declare namespace samchon.protocol { + /** + *

    Base class for web-communicator, {@link WebClientDriver} and {@link WebServerConnector}.

    + * + *

    This class {@link WebCommunicatorBase} subrogates network communication for web-communicator classes, + * {@link WebClinetDriver} and {@link WebServerConnector}. The web-communicator and this class + * {@link WebCommunicatorBase} share same interface {@link IProtocol} and have a chain of responsibily + * relationship.

    + * + *

    When an {@link Invoke} message was delivered from the connected remote system, then this class calls + * web-communicator's {@link WebServerConnector.replyData replyData()} method. Also, when called web-communicator's + * {@link WebClientDriver.sendData sendData()}, then {@link sendData sendData()} of this class will be caleed.

    + * + *
      + *
    • this.replyData() -> communicator.replyData()
    • + *
    • communicator.sendData() -> this.sendData()
    • + *
    + * + * @author Jeongho Nam + */ + class WebCommunicator extends CommunicatorBase { + /** + * Connection driver, a socket for web-socket. + */ + protected connection: websocket.connection; + /** + * Close the connection. + */ + close(): void; + /** + * @inheritdoc + */ + sendData(invoke: Invoke): void; + /** + *

    Handle raw-data received from the remote system.

    + * + *

    Queries raw-data received from the remote system. When the raw-data represents an formal {@link Invoke} + * message, then it will be sent to the {@link replyData}.

    + * + * @param message A raw-data received from the remote system. + */ + protected handle_message(message: websocket.IMessage): void; + protected handle_close(): void; + } +} +declare namespace samchon.protocol { + class SharedWorkerCommunicator extends CommunicatorBase { + protected port: MessagePort; + close(): void; + /** + * @inheritdoc + */ + sendData(invoke: Invoke): void; + protected handle_message(event: MessageEvent): void; + } +} +declare namespace samchon.protocol { + /** + *

    An interface for communicator with connected client.

    + * + *

    {@link IClientDriver} is a type of {@link ICommunicator}, specified for communication with connected client + * in a server. It takes full charge of network communication with the connected client.

    + * + *

    {@link IClientDriver} is created in {@link IServer} and delivered via + * {@link IServer.addClient IServer.addClient()}. Those are derived types from this {@link IClientDriver}, being + * created by matched {@link IServer} object.

    + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
    Derived Type Created By
    {@link ClientDrvier} {@link Server}
    {@link WebClientDrvier} {@link WebServer}
    {@link SharedWorkerClientDrvier} {@link SharedWorkerServer}
    + * + *

    + * + *

    + * + *

    When you've got an {@link IClientDriver} object from the {@link IServer.addClient IServer.addClient()}, then + * specify {@link CommunicatorBase.listener listener} with {@link IClient.listen IClient.listen()}. Below codes are + * an example specifying and managing the {@link CommunicatorBase.listener listener} objects.

    + * + * + /// + /// + + // IMPORTS + import std = require("typescript-stl"); + import samchon = require("samchon-framework"); + + // SHORTCUTS + import library = samchon.library; + import protocol = samchon.protocol; + + class CalculatorServer extends protocol.Server + { + private clients: std.HashSet; + + // WHEN A CLIENT HAS CONNECTED + public addClient(driver: IClientDriver): void + { + let client: CalculatorClient = new CalculatorClient(this, driver); + this.clients.insert(client); + } + } + + class CalculatorClient extends protocol.IProtocol + { + // PARENT SERVER INSTANCE + private server: CalculatorServer; + + // COMMUNICATOR, SENDS AND RECEIVES NETWORK MESSAGE WITH CONNECTED CLIENT + private driver: protocol.IClientDriver; + + ///// + // CONSTRUCTORS + ///// + public constructor(server: CalculatorServer, driver: protocol.IClientDriver) + { + this.server = server; + this.driver = driver; + + // START LISTENING AND RESPOND CLOSING EVENT + this.driver.listen(this); // INVOKE MESSAGE WILL COME TO HERE + this.driver.onClose = this.destructor.bind(this); // DISCONNECTED HANDLER + } + public destructor(): void + { + // WHEN DISCONNECTED, THEN ERASE THIS OBJECT FROM CalculatorServer.clients. + this.server["clients"].erase(this); + } + + ///// + // INVOKE MESSAGE CHAIN + ///// + public sendData(invoke: protocol.Invoke): void + { + // CALL ICommunicator.sendData(), WHO PHYSICALLY SEND NETWORK MESSAGE + this.driver.sendData(invoke); + } + public replyData(invoke: protocol.Invoke): void + { + // FIND MATCHED MEMBER FUNCTION NAMED EQUAL TO THE invoke.getListener() + invoke.apply(this); + } + } + * + * + * + *

    Basic Components

    + *

    What Basic Components are

    + *

    Basic Components are the smallest unit of network communication in this Samchon Framework. With + * Basic Components, you can construct any type of network system, even how the network system is enormously + * scaled and complicated, by just combinating the Basic Components.

    + * + *

    All the system templates in this framework are also being implemented by utilization of the + * Basic Compoonents.

    + * + *
      + *
    • {@link service Service} + *
    • {@link external External System} + *
    • {@link parallel Parallel System} + *
    • {@link distributed Distributed System} + *
    + * + *

    Note that, whatever the network system what you've to construct is, just concentrate on role of each system + * and attach matched Basic Components to the role, within framework of the Object-Oriented Design. + * Then construction of the network system will be much easier.

    + * + *
      + *
    • A system is a server, then use {@link IServer} or {@link IServerBase}.
    • + *
    • A server wants to handle a client has connected, then use {@link IClientDriver}.
    • + *
    • A system is a client connecting to an external server, then use {@link IServerConnector}.
    • + *
    • + *
    + * + *

    Example - System Templates

    + *

    Learning and understanding Basic Components of Samchon Framework, reading source codes and design of + * System Templates' modules will be very helpful.

    + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
    Name Source API Documents
    Cloud Service protocol/service {@link protocol.service}
    External System protocol/external {@link protocol.external}
    Parallel System protocol/parallel {@link protocol.parallel}
    Distributed System protocol/distributed {@link protocol.distributed}
    Slave System protocol/slave {@link protocol.slave}
    + * + *

    Example - Projects

    + * + * + * @see {@link IServer} + * @handbook Basic Components - IClientDriver + * @author Jeongho Nam + */ + interface IClientDriver extends ICommunicator { + /** + *

    Listen message from the newly connected client.

    + * + *

    Starts listening message from the newly connected client. Replied message from the connected client will + * be converted to {@link Invoke} classes and shifted to the listener's + * {@link IProtocol.replyData replyData()} method.

    + * + * @param listener A listener object to listen replied message from newly connected client in + * {@link IProtocol.replyData replyData()} as an {@link Invoke} message. + */ + listen(listener: IProtocol): void; + } +} +declare namespace samchon.protocol { + class ClientDriver extends Communicator implements IClientDriver { + constructor(socket: socket.socket); + /** + * @inheritdoc + */ + listen(listener: IProtocol): void; + } +} +declare namespace samchon.protocol { + class WebClientDriver extends WebCommunicator implements IClientDriver { + /** + * Requested path. + */ + private path; + /** + * Session ID, an identifier of the remote client. + */ + private session_id; + private listening; + /** + * Initialization Constructor. + * + * @param connection Connection driver, a socket for web-socket. + * @param path Requested path. + * @param session_id Session ID, an identifier of the remote client. + */ + constructor(connection: websocket.connection, path: string, session_id: string); + /** + * @inheritdoc + */ + listen(listener: IProtocol): void; + /** + * Get requested path. + */ + getPath(): string; + /** + * Get session ID, an identifier of the remote client. + */ + getSessionID(): string; + } +} +declare namespace samchon.protocol { + class SharedWorkerClientDriver extends SharedWorkerCommunicator implements IClientDriver { + private listening; + constructor(port: MessagePort); + /** + * @inheritdoc + */ + listen(listener: IProtocol): void; + } +} +declare namespace samchon.protocol { + abstract class DedicatedWorker implements IProtocol { + private communicator_; + /** + * Default Constructor. + */ + constructor(); + abstract replyData(invoke: protocol.Invoke): void; + sendData(invoke: Invoke): void; + } +} +declare namespace samchon.protocol { + class DedicatedWorkerConnector extends CommunicatorBase implements IServerConnector { + private worker; + /** + * @inheritdoc + */ + onConnect: Function; + /** + * @inheritdoc + */ + onClose: Function; + constructor(listener: IProtocol); + /** + * @inheritdoc + */ + connect(jsFile: string): void; + /** + * @inheritdoc + */ + close(): void; + sendData(invoke: Invoke): void; + replyData(invoke: Invoke): void; + private handle_message(event); + } +} declare namespace samchon.protocol { interface IEntityGroup extends IEntity, std.base.IContainer { /** @@ -2368,7 +3578,6 @@ declare namespace samchon.protocol { * * @return A new child Entity belongs to EntityArray. */ - createChild(xml: library.XML): T; /** *

    Get iterator to element.

    * @@ -2444,9 +3653,15 @@ declare namespace samchon.protocol { */ construct(xml: library.XML): void; /** - * @inheritdoc + *

    Factory method of a child Entity.

    + * + *

    EntityArray::createChild() is a factory method creating a new child Entity which is belonged + * to the EntityArray. This method is called by EntityArray::construct(). The children construction + * methods Entity::construct() will be called by abstract method of the EntityArray::construct().

    + * + * @return A new child Entity belongs to EntityArray. */ - abstract createChild(xml: library.XML): T; + protected abstract createChild(xml: library.XML): T; /** * @inheritdoc */ @@ -2488,9 +3703,15 @@ declare namespace samchon.protocol { */ construct(xml: library.XML): void; /** - * @inheritdoc + *

    Factory method of a child Entity.

    + * + *

    EntityArray::createChild() is a factory method creating a new child Entity which is belonged + * to the EntityArray. This method is called by EntityArray::construct(). The children construction + * methods Entity::construct() will be called by abstract method of the EntityArray::construct().

    + * + * @return A new child Entity belongs to EntityArray. */ - abstract createChild(xml: library.XML): T; + protected abstract createChild(xml: library.XML): T; /** * @inheritdoc */ @@ -2532,9 +3753,15 @@ declare namespace samchon.protocol { */ construct(xml: library.XML): void; /** - * @inheritdoc + *

    Factory method of a child Entity.

    + * + *

    EntityArray::createChild() is a factory method creating a new child Entity which is belonged + * to the EntityArray. This method is called by EntityArray::construct(). The children construction + * methods Entity::construct() will be called by abstract method of the EntityArray::construct().

    + * + * @return A new child Entity belongs to EntityArray. */ - abstract createChild(xml: library.XML): T; + protected abstract createChild(xml: library.XML): T; /** * @inheritdoc */ @@ -2583,9 +3810,15 @@ declare namespace samchon.protocol { */ construct(xml: library.XML): void; /** - * @inheritdoc + *

    Factory method of a child Entity.

    + * + *

    EntityArray::createChild() is a factory method creating a new child Entity which is belonged + * to the EntityArray. This method is called by EntityArray::construct(). The children construction + * methods Entity::construct() will be called by abstract method of the EntityArray::construct().

    + * + * @return A new child Entity belongs to EntityArray. */ - abstract createChild(xml: library.XML): T; + protected abstract createChild(xml: library.XML): T; /** * @inheritdoc */ @@ -2627,9 +3860,15 @@ declare namespace samchon.protocol { */ construct(xml: library.XML): void; /** - * @inheritdoc + *

    Factory method of a child Entity.

    + * + *

    EntityArray::createChild() is a factory method creating a new child Entity which is belonged + * to the EntityArray. This method is called by EntityArray::construct(). The children construction + * methods Entity::construct() will be called by abstract method of the EntityArray::construct().

    + * + * @return A new child Entity belongs to EntityArray. */ - abstract createChild(xml: library.XML): T; + protected abstract createChild(xml: library.XML): T; /** * @inheritdoc */ @@ -2671,9 +3910,15 @@ declare namespace samchon.protocol { */ construct(xml: library.XML): void; /** - * @inheritdoc + *

    Factory method of a child Entity.

    + * + *

    EntityArray::createChild() is a factory method creating a new child Entity which is belonged + * to the EntityArray. This method is called by EntityArray::construct(). The children construction + * methods Entity::construct() will be called by abstract method of the EntityArray::construct().

    + * + * @return A new child Entity belongs to EntityArray. */ - abstract createChild(xml: library.XML): T; + protected abstract createChild(xml: library.XML): T; /** * @inheritdoc */ @@ -2709,203 +3954,238 @@ declare namespace samchon.protocol { } declare namespace samchon.protocol { /** - *

    A network driver for an external system.

    + *

    An interface for {@link Invoke} message chain.

    * - *

    ExternalSystem is a boundary class interacting with an external system by network communication. - * Also, ExternalSystem is an abstract class that a network role, which one is server and which one is - * client, is not determined yet.

    + *

    {@link IProtocol} is an interface for {@link Invoke} message, which is standard message of network I/O in + * Samchon Framework, chain. The {@link IProtocol} interface is used to network drivers and some classes + * which are in a relationship of Chain of Responsibility Pattern with those network drivers.

    * - *

    The ExternalSystem has ExternalSystemRole(s) groupped methods, handling Invoke message - * interacting with the external system, by subject or unit of a moudle. The ExternalSystemRole is - * categorized in a 'control'.

    + *

    Implements {@link IProtocol} if the class sends and handles {@link Invoke} message. Looking around source + * codes of Samchon Framework, especially System Templates, you can find out that all the classes and + * modules handling {@link Invoke} messages are always implementing this {@link IProtocol} . Yes, {@link IProtocol}, + * this is the main role you've to follow in this Samchon Framework.

    * - *

    Note

    - *

    The ExternalSystem class takes a role of interaction with external system in network level. - * However, within a framework of Samchon Framework, a boundary class like the ExternalSystem is - * not such important. You can find some evidence in a relationship between ExternalSystemArray, - * ExternalSystem and ExternalSystemRole.

    + *

    + * + *

    * - *

    Of course, the ExternalSystemRole is belonged to an ExternalSystem. However, if you - * access an ExternalSystemRole from an ExternalSystemArray directly, not passing by a belonged - * ExternalSystem, and send an Invoke message even you're not knowing which ExternalSystem is - * related in, it's called "Proxy pattern". * - *

    Like the explanation of "Proxy pattern", you can utilize an ExternalSystemRole as a proxy - * of an ExternalSystem. With the pattern, you can only concentrate on ExternalSystemRole itself, - * what to do with Invoke message, irrespective of the ExternalSystemRole is belonged to which - * ExternalSystem.

    - * - * @author Jeongho Nam - */ - abstract class ExternalSystem extends EntityArray implements IProtocol { - /** - *

    A driver for interacting with (real, physical) external system.

    - */ - protected driver: ServerConnector; - /** - *

    A name can identify an external system.

    - * - *

    The name must be unique in ExternalSystemArray.

    - */ - protected name: string; - /** - *

    An ip address of an external system.

    - */ - protected ip: string; - /** - *

    A port number of an external system.

    - */ - protected port: number; - /** - *

    Default Constructor.

    - */ - constructor(); - /** - *

    Start interaction.

    - *

    An abstract method starting interaction with an external system.

    - * - *

    If an external systems are a server, starts connection and listening Inovoke message, - * else clients, just starts listening only. You also can addict your own procudures of starting - * the driver, but if you directly override method of abstract ExternalSystem, be careful about - * virtual inheritance.

    - */ - start(): void; - key(): any; - /** - *

    Get name.

    - */ - getName(): string; - /** - *

    Get ip address of the external system.

    - */ - getIP(): string; - /** - *

    Get port number of the external system.

    - */ - getPort(): number; - sendData(invoke: Invoke): void; - replyData(invoke: Invoke): void; - TAG(): string; - CHILD_TAG(): string; - } -} -declare namespace samchon.protocol { - /** - *

    An array of ExternalSystem(s).

    - * - *

    ExternalSystemArray is an abstract class containing and managing external system drivers.

    - * - *

    Also, ExternalSystemArray can access to ExternalSystemRole(s) directly. With the method, you - * can use an ExternalSystemRole as "logical proxy" of an ExternalSystem. Of course, the - * ExternalSystemRole is belonged to an ExternalSystem. However, if you access an ExternalSystemRole - * from an ExternalSystemArray directly, not passing by a belonged ExternalSystem, and send an Invoke - * message even you're not knowing which ExternalSystem is related in, the ExternalSystemRole acted - * a role of proxy.

    - * - *

    It's called as "Proxy pattern". With the pattern, you can only concentrate on - * ExternalSystemRole itself, what to do with Invoke message, irrespective of the ExternalSystemRole - * is belonged to which ExternalSystem.

    + *

    Utilization Case

    + *

    Below pseudo code and class diagram represents {@link service Service Module}, who can build a cloud server. + * All the classes in the pseudo code are implementing the {@link IProtocol} because all of them are handling + * {@link Invoke} message.

    * *
      - *
    • ExternalSystemArray::getRole("something")->sendData(invoke);
    • + *
    • Server: Represents a server literally
    • + *
    • User: Represents an user being identified by its session id. User contains multiple Client objects.
    • + *
        + *
      • In browser, an user can open multiple windows. + *
          + *
        • User: A browser (like IE, Chrome and Safari). + *
        • Client: An internet browser window + *
        + *
      • + *
      + *
    • Client: Represents a browser window and it takes role of network communication with it.
    • + *
    • Service: Represents a service, domain logic.
    • *
    * - * @author Jeongho Nam - */ - abstract class ExternalSystemArray extends EntityArray implements IProtocol { - /** - * Default Constructor. - */ - constructor(); - /** - *

    Start interaction.

    - *

    An abstract method starting interaction with external systems.

    - * - *

    If external systems are servers, starts connection to them, else clients, opens a server - * and accepts the external systems. You can addict your own procudures of starting drivers, but - * if you directly override method of abstract ExternalSystemArray, be careful about virtual - * inheritance.

    - */ - start(): void; - /** - *

    Test whether has a role.

    - * - * @param name Name of an ExternalSystemRole. - * @return Whether has or not. - */ - hasRole(key: string): boolean; - /** - *

    Get a role.

    - * - * @param name Name of an ExternalSystemRole - * @return A shared pointer of specialized role - */ - getRole(key: string): ExternalSystemRole; - sendData(invoke: Invoke): void; - replyData(invoke: Invoke): void; - TAG(): string; - CHILD_TAG(): string; + *

    + * + *

    + * + * + /// + /// + + // IMPORTS + import std = require("typescript-stl"); + import samchon = require("samchon-framework"); + + // SHORTCUTS + import library = samchon.library; + import collection = samchon.collection; + import protocol = samchon.protocol; + + namespace service + { + export class Server extends protocol.WebServer implements IProtocol + { + // SERVER HAS MULTIPLE USER OBJECTS + private session_map: std.HashMap; + + //------------------------ + // MESSAGE CHAIN + //------------------------ + public sendData(invoke: protocol.Invoke): void + { + // SEND INVOKE MESSAGE TO ALL USER OBJECTS + for (let it = this.session_map.begin(); !it.equal_to(this.session_map.end()); it = it.next()) + it.second.sendData(invoke); + } + public replyData(invoke: protocol.Invoke): void + { + invoke.apply(this); // HANDLE INVOKE MESSAGE BY ITSELF + } + } + + export class User extends + collection.HashMapCollection // USER HAS MULTIPLE CLIENT OBJECTS + implements IProtocol + { + private server: Server; // USER REFRES SERVER + + //------------------------ + // MESSAGE CHAIN + //------------------------ + public sendData(invoke: protocol.Invoke): void + { + // SEND INVOKE MESSAGE TO ALL CLIENT OBJECTS + for (let it = this.begin(); !it.equal_to(this.end()); it = it.next()) + it.second.sendData(invoke); + } + public replyData(invoke: protocol.Invoke): void + { + invoke.apply(this); // HANDLE INOVKE MESSAGE BY ITSELF + this.server.replyData(invoke); // OR VIA SERVER + } + } + + export class Client implements IProtocol + { + private user: User; // CLIENT REFERS USER + private service: Service; // CLIENT HAS A SERVICE OBJECT + + private driver: WebClientDriver; + + //------------------------ + // MESSAGE CHAIN + //------------------------ + public sendData(invoke: protocol.Invoke): void + { + // SEND INVOKE MESSAGE VIA driver: WebClientDriver + this.driver.sendData(invoke); + } + public replyData(invoke: protocol.Invoke): void + { + invoke.apply(this); // HANDLE INOVKE MEESAGE BY ITSELF + this.user.replyData(invoke); // OR VIA USER + + if (this.service != null) // OR VIA SERVICE + this.service.replyData(invoke); + } + } + + export class Service implements IProtocol + { + private client: Client; // SERVICE REFRES CLIENT + + //------------------------ + // MESSAGE CHAIN + //------------------------ + public sendData(invoke: protocol.Invoke): void + { + // SEND INVOKE MESSAGE VIA CLIENT + return this.client.sendData(invoke); + } + public replyData(invoke: protocol.Invoke): void + { + invoke.apply(this); // HANDLE INVOKE MESSAGE BY ITSELF + } + } } -} -declare namespace samchon.protocol { - /** - *

    A role belongs to an external system.

    + *
    * - *

    ExternalSystemRole is a 'control' class groupping methods, handling Invoke messages - * interacting with an external system that the ExternalSystemRole is belonged to, by a subject or - * unit of a module.

    * - *

    ExternalSystemRole can be a "logical proxy" for an ExternalSystem which is containing the - * ExternalSystemRole. Of course, the ExternalSystemRole is belonged to an ExternalSystem. However, - * if you access an ExternalSystemRole from an ExternalSystemArray directly, not passing by a - * belonged ExternalSystem, and send an Invoke message even you're not knowing which ExternalSystem - * is related in, the ExternalSystemRole acted a role of proxy.

    + *

    Basic Components

    + *

    What Basic Components are

    + *

    Basic Components are the smallest unit of network communication in this Samchon Framework. With + * Basic Components, you can construct any type of network system, even how the network system is enormously + * scaled and complicated, by just combinating the Basic Components.

    * - *

    It's called as "Proxy pattern". With the pattern, you can only concentrate on - * ExternalSystemRole itself, what to do with Invoke message, irrespective of the ExternalSystemRole - * is belonged to which ExternalSystem.

    + *

    All the system templates in this framework are also being implemented by utilization of the + * Basic Compoonents.

    * - * @author Jeongho Nam - */ - class ExternalSystemRole extends Entity implements IProtocol { - /** - *

    A driver of external system containing the ExternalSystemRole.

    - */ - protected system: ExternalSystem; - /** - *

    A name representing the role.

    - */ - protected name: string; - protected sendListeners: std.HashSet; - /** - *

    Construct from external system driver.

    - * - * @param system A driver of external system the ExternalSystemRole is belonged to. - */ - constructor(system: ExternalSystem); - construct(xml: library.XML): void; - getName(): string; - hasSendListener(key: string): boolean; - sendData(invoke: Invoke): void; - replyData(invoke: Invoke): void; - TAG(): string; - toXML(): library.XML; - } -} -declare namespace samchon.protocol { - /** - *

    An interface for Invoke message chain.

    + *
      + *
    • {@link service Service} + *
    • {@link external External System} + *
    • {@link parallel Parallel System} + *
    • {@link distributed Distributed System} + *
    * - *

    IProtocol is an interface for Invoke message, which is standard message of network I/O - * in Samchon Framework, chain. The IProtocol interface is used to network drivers and some - * classes which are in a relationship of chain of responsibility with those network drivers.

    + *

    Note that, whatever the network system what you've to construct is, just concentrate on role of each system + * and attach matched Basic Components to the role, within framework of the Object-Oriented Design. + * Then construction of the network system will be much easier.

    * - *

    In Samchon Framework, server side, IProtocol is one of the basic 3 + 1 components that - * can make any type of network system in Samchon Framework with IServer and IClient. Following - * the "chain of responsibility" pa1ttern, looking around classes in Samchon Framework, you - * can see all related classes with network I/O are implemented from the IProtocol.

    + *
      + *
    • A system is a server, then use {@link IServer} or {@link IServerBase}.
    • + *
    • A server wants to handle a client has connected, then use {@link IClientDriver}.
    • + *
    • A system is a client connecting to an external server, then use {@link IServerConnector}.
    • + *
    • + *
    * - * @see Invoke + *

    Example - System Templates

    + *

    Learning and understanding Basic Components of Samchon Framework, reading source codes and design of + * System Templates' modules will be very helpful.

    + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
    Name Source API Documents
    Cloud Service protocol/service {@link protocol.service}
    External System protocol/external {@link protocol.external}
    Parallel System protocol/parallel {@link protocol.parallel}
    Distributed System protocol/distributed {@link protocol.distributed}
    Slave System protocol/slave {@link protocol.slave}
    + * + *

    Example - Projects

    + * + * + * @see {@link Invoke} + * @handbook Basic Components - IProtocol * @author Jeongho Nam */ interface IProtocol { @@ -2920,7 +4200,7 @@ declare namespace samchon.protocol { *

    Handling replied message.

    *

    Handles replied message or shifts the responsibility to chain.

    * - * @param invoke Replied invoke message + * @param invoke An {@link Invoke} message has received. */ sendData(invoke: Invoke): void; } @@ -2928,7 +4208,8 @@ declare namespace samchon.protocol { declare namespace samchon.protocol { /** *

    Standard message of network I/O.

    - *

    Invoke is a class used in network I/O in protocol package of Samchon Framework.

    + * + *

    {@link Invoke} is a class used in network I/O in protocol package of Samchon Framework.

    * *

    The Invoke message has an XML structure like the result screen of provided example in below. * We can enjoy lots of benefits by the normalized and standardized message structure used in @@ -2940,8 +4221,8 @@ declare namespace samchon.protocol { * like a object (class) in OOD. And those relationships can be easily designed by using design * pattern.

    * - *

    In Samchon Framework, you can make any type of network system with basic 3 + 1 componenets - * (IProtocol, IServer and IClient + ServerConnector), by implemens or inherits them, like designing + *

    In Samchon Framework, you can make any type of network system with basic componenets + * (IProtocol, IServer and ICommunicator) by implemens or inherits them, like designing * classes of S/W architecture.

    * * @see IProtocol @@ -2952,6 +4233,10 @@ declare namespace samchon.protocol { *

    Listener, represent function's name.

    */ protected listener: string; + /** + * Default Constructor. + */ + constructor(); constructor(listener: string); /** * Copy Constructor. @@ -2959,13 +4244,17 @@ declare namespace samchon.protocol { * @param invoke */ constructor(invoke: Invoke); - constructor(xml: library.XML); - constructor(listener: string, begin: std.VectorIterator, end: std.VectorIterator); - constructor(listener: string, ...parameters: any[]); + /** + * Construct from listener and parametric values. + * + * @param listener + * @param parameters + */ + constructor(listener: string, ...parameters: Array); /** * @inheritdoc */ - createChild(xml: library.XML): InvokeParameter; + protected createChild(xml: library.XML): InvokeParameter; /** * Get listener. */ @@ -2990,93 +4279,10 @@ declare namespace samchon.protocol { CHILD_TAG(): string; } } -declare namespace samchon.protocol { - /** - *

    A history of an Invoke message.

    - * - *

    InvokeHistory is a class for reporting history log of an Invoke message with elapsed time - * from a slave to its master.

    - * - *

    With the elapsed time, consumed time for a process of handling the Invoke message, - * InvokeHistory is reported to the master. The master utilizies the elapsed time to estimating - * performances of each slave system. With the estimated performan index, master retrives the - * optimal solution of distributing processes.

    - * - * @author Jeongho Nam - */ - class InvokeHistory extends Entity { - /** - *

    An identifier.

    - */ - protected uid: number; - /** - *

    A listener of the Invoke message.

    - * - *

    InvokeHistory does not archive entire data of an Invoke message. InvokeHistory only - * archives its listener. The first, formal reason is to save space, avoid wasting spaces.

    - * - *

    The second, complicate reason is on an aspect of which systems are using the - * InvokeHistory class. InvokeHistory is designed to let slave reports to master elapsed time - * of a process used to handling the Invoke message. If you want to archive entire history log - * of Invoke messages, then the subject should be master, not the slave using InvokeHistory - * classes.

    - */ - protected listener: string; - /** - *

    Start time of the history.

    - * - *

    Means start time of a process handling the Invoke message. The start time not only - * has ordinary arguments represented Datetime (year to seconds), but also has very precise - * values under seconds, which is expressed as nano seconds (10^-9).

    - * - *

    The precise start time will be used to calculate elapsed time with end time.

    - */ - protected startTime: Date; - /** - *

    End time of the history.

    - * - * @details - *

    Means end time of a process handling the Invoke message. The end time not only - * has ordinary arguments represented Datetime (year to seconds), but also has very precise - * values under seconds, which is expressed as nano seconds (10^-9).

    - * - *

    The precise end time will be used to calculate elapsed time with start time.

    - */ - protected endTime: Date; - /** - *

    Construct from an Invoke message.

    - * - *

    InvokeHistory does not archive entire Invoke message, only archives its listener.

    - * - * @param invoke A message to archive its history log - */ - constructor(invoke: Invoke); - /** - *

    Notify end of the process.

    - * - *

    Notifies end of a process handling the matched Invoke message to InvokeHistory.

    - *

    InvokeHistory archives the end datetime and calculates elapsed time as nanoseconds.

    - */ - notifyEnd(): void; - TAG(): string; - toXML(): library.XML; - /** - *

    Get an Invoke message.

    - * - *

    Returns an Invoke message to report to a master that how much time was elapsed on a - * process handling the Invoke message. In master, those reports are used to estimate - * performance of each slave system.

    - * - * @return An Invoke message to report master. - */ - toInvoke(): Invoke; - } -} declare namespace samchon.protocol { /** * A parameter belongs to an Invoke. * - * @see Invoke * @author Jeongho Nam */ class InvokeParameter extends Entity { @@ -3093,31 +4299,33 @@ declare namespace samchon.protocol { /** *

    Value of the parameter.

    */ - protected value: any; + protected value: string | number | library.XML | Uint8Array; /** * Default Constructor. */ constructor(); + constructor(val: number); + constructor(val: string); + constructor(val: library.XML); + constructor(val: Uint8Array); /** - * Initialization Constructor without type specification. + * Construct from variable name and number value. * * @param name * @param val */ - constructor(name: string, val: any); - /** - * Initialization Constructor. - * - * @param name - * @param type - * @param val - */ - constructor(name: string, type: string, val: any); + constructor(name: string, val: number); + constructor(name: string, val: string); + constructor(name: string, val: library.XML); + constructor(name: string, val: Uint8Array); /** * @inheritdoc */ construct(xml: library.XML): void; - setValue(value: any): void; + setValue(value: number): any; + setValue(value: string): any; + setValue(value: library.XML): any; + setValue(value: Uint8Array): any; /** * @inheritdoc */ @@ -3145,193 +4353,1781 @@ declare namespace samchon.protocol { } } declare namespace samchon.protocol { - /** - *

    A server connector for a physical client.

    - * - *

    ServerConnector is a class for a physical client connecting a server. If you want to connect - * to a server, then implements this ServerConnector and just override some methods like - * getIP(), getPort() and replyData(). That's all.

    - * - *

    In Samchon Framework, package protocol, There are basic 3 + 1 components that can make any - * type of network system in Samchon Framework. The basic 3 components are IProtocol, IServer and - * IClient. The last, surplus one is the ServerConnector. Looking around classes in - * Samchon Framework, especially module master and slave which are designed for realizing - * distributed processing systems and parallel processing systems, physical client classes are all - * derived from this ServerConnector.

    - * - * - * - * @author Jeongho Nam - */ - class ServerConnector implements IProtocol { + class InvokeHistory extends Entity { /** - *

    A parent object who listens and sends Invoke message.

    * - *
      - *
    • ServerConnector.replyData(Invoke) -> parent.replyData(Invoke)
    • - *
    */ - private parent; + private uid; /** - *

    A socket for network I/O.

    + * @see {@link Invoke.listener} */ - private socket; - private binary_invoke; + private listener; /** - *

    An open-event listener.

    - */ - onopen: Function; - /** - *

    Constructor with parent.

    - */ - constructor(parent: IProtocol); - /** - *

    Connects to a cloud server with specified host and port.

    * - *

    If the connection fails immediately, either an event is dispatched or an exception is thrown: - * an error event is dispatched if a host was specified, and an exception is thrown if no host - * was specified. Otherwise, the status of the connection is reported by an event. - * If the socket is already connected, the existing connection is closed first.

    + */ + private startTime; + /** * - * @param ip - * The name or IP address of the host to connect to. - * If no host is specified, the host that is contacted is the host where the calling - * file resides. If you do not specify a host, use an event listener to determine whether - * the connection was successful. - * @param port - * The port number to connect to. - * - * @throws IOError - * No host was specified and the connection failed. - * @throws SecurityError - * This error occurs in SWF content for the following reasons: - * Local untrusted SWF files may not communicate with the Internet. You can work around - * this limitation by reclassifying the file as local-with-networking or as trusted. */ - connect(ip: string, port: number, path?: string): void; + private endTime; /** - *

    Send data to the server.

    + * Default Constructor. */ - sendData(invoke: Invoke): void; - /** - *

    Shift responsiblity of handling message to parent.

    - */ - replyData(invoke: Invoke): void; - private handleConnect(event); - /** - *

    Handling replied message.

    - */ - private handleReply(event); + constructor(); + constructor(invoke: Invoke); + construct(xml: library.XML): void; + notifyEnd(): void; + key(): number; + getUID(): number; + getListener(): string; + getStartTime(): Date; + getEndTime(): Date; + computeElapsedTime(): number; + TAG(): string; + toXML(): library.XML; + toInvoke(): Invoke; } } -declare namespace samchon.protocol.service { +declare namespace samchon.protocol { /** - *

    An application, the top class in JS-UI.

    + *

    An interface for a physical server.

    + * + *

    {@link IServer} provides methods for opening a server. Extends one of them who are derived from this + * {@link IServer} and open the server with method {@link open IServer.open()}. Override + * {@link addClient IServer.addClient()} who accepts a newly connected client with {@link IClientDriver}. + * If you're embarrased because your class already extended another one, then use {@link IServerBase}.

    * - *

    The Application is separated to three part, TopMenu, Movie and ServerConnector.

    *
      - *
    • TopMenu: Menu on the top. It's not an essential component.
    • - *
    • Movie: Correspond with Service in Server. Movie has domain UI components(Movie) for the matched Service.
    • - *
    • ServerConnector: The socket connecting to the Server.
    • + *
    • {@link Server}
    • + *
    • {@link WebServer}
    • + *
    • {@link SharedWorkerServer}
    • *
    * - *

    The Application and its UI-layout is not fixed, essential component for Samchon Framework in Flex, - * so it's okay to do not use the provided Application and make your custom Application. - * But the custom Application, your own, has to contain the Movie and keep the construction routine.

    + *

    + * + *

    * - *

    + *

    Basic Components

    + *

    What Basic Components are

    + *

    Basic Components are the smallest unit of network communication in this Samchon Framework. With + * Basic Components, you can construct any type of network system, even how the network system is enormously + * scaled and complicated, by just combinating the Basic Components.

    + * + *

    All the system templates in this framework are also being implemented by utilization of the + * Basic Compoonents.

    * - *

    THE CONSTRUCTION ROUTINE

    *
      - *
    • Socket Connection
    • - *
        - *
      • Connect to the CPP-Server
      • - *
      - *
    • Fetch authority
    • - *
        - *
      • Send a request to fetching authority
      • - *
      • The window can be navigated to other page by the authority
      • - *
      - *
    • Construct Movie
    • - *
        - *
      • Determine a Movie by URLVariables::movie and construct it
      • - *
      - *
    • All the routines are done
    • + *
    • {@link service Service} + *
    • {@link external External System} + *
    • {@link parallel Parallel System} + *
    • {@link distributed Distributed System} *
    * + *

    Note that, whatever the network system what you've to construct is, just concentrate on role of each system + * and attach matched Basic Components to the role, within framework of the Object-Oriented Design. + * Then construction of the network system will be much easier.

    + * + *
      + *
    • A system is a server, then use {@link IServer} or {@link IServerBase}.
    • + *
    • A server wants to handle a client has connected, then use {@link IClientDriver}.
    • + *
    • A system is a client connecting to an external server, then use {@link IServerConnector}.
    • + *
    • + *
    + * + *

    Example - System Templates

    + *

    Learning and understanding Basic Components of Samchon Framework, reading source codes and design of + * System Templates' modules will be very helpful.

    + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
    Name Source API Documents
    Cloud Service protocol/service {@link protocol.service}
    External System protocol/external {@link protocol.external}
    Parallel System protocol/parallel {@link protocol.parallel}
    Distributed System protocol/distributed {@link protocol.distributed}
    Slave System protocol/slave {@link protocol.slave}
    + * + *

    Example - Projects

    + * + * + * @see {@link IClientDriver} + * @handbook Basic Components - IServer * @author Jeongho Nam */ - class Application implements IProtocol { - /** - *

    Invoke Socket.

    - */ - protected socket: ServerConnector; - /** - *

    A movie.

    - */ - protected movie: Movie; - /** - *

    Construct from arguments.

    - * - * @param movie A movie represents a service. - * @param ip An ip address of cloud server to connect. - * @param port A port number of cloud server to connect. - */ - constructor(movie: Movie, ip: string, port: number); - private handleConnect(event); - /** - *

    Handle replied message or shift the responsibility.

    - */ - replyData(invoke: Invoke): void; - /** - *

    Send a data to server.

    - */ - sendData(invoke: Invoke): void; + interface IServer { + open(port: number): void; + close(): void; + addClient(clientDriver: IClientDriver): void; } } -declare namespace samchon.protocol.service { - /** - * A movie belonged to an Application. - */ - class Movie implements IProtocol { +declare namespace samchon.protocol { + abstract class Server implements IServer { + private server; /** - *

    An application the movie is belonged to + * @inheritdoc */ - protected application: Application; + abstract addClient(driver: ClientDriver): void; /** - * Handle replied data. + * @inheritdoc */ - replyData(invoke: Invoke): void; + open(port: number): void; /** - * Send data to server. + * @inheritdoc */ - sendData(invoke: Invoke): void; + close(): void; + private handle_connect(socket); } } -declare namespace samchon.protocol.service { -} -declare namespace samchon.protocol.slave { - /** - * @brief A slave system. - * - * @details - *

    SlaveSystem, literally, means a slave system belongs to a maste system.

    - * - *

    The SlaveSystem class is used in opposite side system of master::DistributedSystem - * and master::ParallelSystem and reports elapsed time of each commmand (by Invoke message) - * for estimation of its performance.

    - * - * @inheritdoc - * @author Jeongho Nam - */ - abstract class SlaveSystem extends ExternalSystem { +declare namespace samchon.protocol { + abstract class WebServer implements IServer { /** - *

    Default Constructor.

    + * A server handler. + */ + private http_server; + /** + * Sequence number for issuing session id. + */ + private sequence; + /** + * @hidden + */ + private my_port; + /** + * Default Constructor. */ constructor(); /** * @inheritdoc */ + open(port: number): void; + /** + * @inheritdoc + */ + close(): void; + /** + * @inheritdoc + */ + abstract addClient(driver: WebClientDriver): void; + /** + *

    Handle request from a client system.

    + * + *

    This method {@link handle_request} will be called when a client is connected. It will call an abstract + * method method {@link addClient addClient()} who handles an accepted client. If the newly connected client + * doesn't have its own session id, then a new session id will be issued.

    + * + * @param request Requested header. + */ + private handle_request(request); + /** + *

    Get session id from a newly connected.

    + * + *

    Queries ordinary session id from cookies of a newly connected client. If the client has not, a new + * session id will be issued.

    + * + * @param cookies Cookies from the remote client. + */ + private get_session_id(cookies); + /** + * Issue a new session id. + */ + private issue_session_id(); + } +} +declare namespace samchon.protocol { + abstract class SharedWorkerServer implements IServer { + /** + * @inheritdoc + */ + abstract addClient(driver: SharedWorkerClientDriver): void; + /** + * @inheritdoc + */ + open(): void; + /** + * @inheritdoc + */ + close(): void; + private handle_connect(event); + } +} +declare namespace samchon.protocol { + /** + *

    An interface for substitute server classes.

    + * + *

    {@link IServerBase} is an interface for substitue server classes who subrogate server's role.

    + * + *

    The easiest way to defining a server class is to extending one of them, who are derived from the + * {@link IServer}.

    + * + *
      + *
    • {@link Server}
    • + *
    • {@link WebServer}
    • + *
    • {@link SharedWorkerServer}
    • + *
    + * + *

    However, it is impossible (that is, if the class is already extending another class), you can instead implement + * the {@link IServer} interface, create an {@link IServerBase} member, and write simple hooks to route calls into the + * aggregated {@link IServerBase}.

    + * + *

    {@link ExternalClientArray} can be a good example using this {@link IServerBase}.

    + *
      + *
    • https://github.com/samchon/framework/blob/master/ts/src/samchon/protocol/external/ExternalClientArray.ts
    • + *
    + * + * + class MyServer extends Something implements IServer + { + private server_base: IServerBase = new WebServerBase(this); + + public addClient(driver: IClientDriver): void + { + // WHAT TO DO WHEN A CLIENT HAS CONNECTED + } + + public open(port: number): void + { + this.server_base.open(); + } + public close(): void + { + this.server_base.close(); + } + } + * + * + * @see {@link IServer} + * @handbook Basic Components - IServerBase + * @author Jeongho Nam + */ + interface IServerBase extends IServer { + } +} +declare namespace samchon.protocol { + /** + *

    A substitute {@link Server}.

    + * + *

    {@link ServerBase} is a substitute class who subrogates {@link Server}'s responsibility.

    + * + *

    The easiest way to defning a server class following normal protocol of Samchon Framework is to extending + * {@link Server}. However, it is impossible (that is, if the class is already extending another class), you can + * instead implement the {@link IServer} interface, create a {@link ServerBase} member, and write simple hooks + * to route calls into the aggregated {@link ServerBase}.

    + * + *

    {@link ExternalClientArray} can be a good example using this {@link IServerBase}.

    + *
      + *
    • https://github.com/samchon/framework/blob/master/ts/src/samchon/protocol/external/ExternalClientArray.ts
    • + *
    + * + * + class MyServer extends Something implements IServer + { + private server_base: ServerBase = new ServerBase(this); + + public addClient(driver: ClientDriver): void + { + // WHAT TO DO WHEN A CLIENT HAS CONNECTED + } + + public open(port: number): void + { + this.server_base.open(); + } + public close(): void + { + this.server_base.close(); + } + } + * + * + * @author Jeongho Nam + */ + class ServerBase extends Server implements IServerBase { + private target; + constructor(target: IServer); + addClient(driver: IClientDriver): void; + } +} +declare namespace samchon.protocol { + /** + *

    A substitute {@link WebServer}.

    + * + *

    {@link WebServerBase} is a substitute class who subrogates {@link WebServer}'s responsibility.

    + * + *

    The easiest way to defning a server class following normal protocol of Samchon Framework is to extending + * {@link WebServer}. However, it is impossible (that is, if the class is already extending another class), you can + * instead implement the {@link IServer} interface, create a {@link WebServerBase} member, and write simple hooks to + * route calls into the aggregated {@link WebServerBase}.

    + * + *

    {@link ExternalClientArray} can be a good example using this {@link IServerBase}.

    + *
      + *
    • https://github.com/samchon/framework/blob/master/ts/src/samchon/protocol/external/ExternalClientArray.ts
    • + *
    + * + * + class MyServer extends Something implements IServer + { + private server_base: WebServerBase = new WebServerBase(this); + + public addClient(driver: WebClientDriver): void + { + // WHAT TO DO WHEN A CLIENT HAS CONNECTED + } + + public open(port: number): void + { + this.server_base.open(); + } + public close(): void + { + this.server_base.close(); + } + } + * + * + * @author Jeongho Nam + */ + class WebServerBase extends WebServer implements IServerBase { + private target; + constructor(target: IServer); + addClient(driver: IClientDriver): void; + } +} +declare namespace samchon.protocol { + /** + *

    A substitute {@link SharedWorkerServer}.

    + * + *

    {@link SharedWorkerServerBase} is a substitute class who subrogates {@link SharedWorkerServer}'s + * responsibility.

    + * + *

    The easiest way to defning a server class following normal protocol of Samchon Framework is to extending + * {@link SharedWorkerServer}. However, it is impossible (that is, if the class is already extending another class), + * you can instead implement the {@link IServer} interface, create a {@link SharedWorkerServerBase} member, and write + * simple hooks to route calls into the aggregated {@link SharedWorkerServerBase}.

    + * + *

    {@link ExternalClientArray} can be a good example using this {@link IServerBase}.

    + *
      + *
    • https://github.com/samchon/framework/blob/master/ts/src/samchon/protocol/external/ExternalClientArray.ts
    • + *
    + * + * + class MyServer extends Something implements IServer + { + private server_base: SharedWorkerServerBase = new SharedWorkerServerBase(this); + + public addClient(driver: SharedWorkerClientDriver): void + { + // WHAT TO DO WHEN A CLIENT HAS CONNECTED + } + + public open(port: number): void + { + this.server_base.open(); + } + public close(): void + { + this.server_base.close(); + } + } + * + * + * @author Jeongho Nam + */ + class SharedWorkerServerBase extends SharedWorkerServer implements IServerBase { + private target; + constructor(target: IServer); + addClient(driver: IClientDriver): void; + } +} +declare namespace samchon.protocol { + /** + *

    An interface for server connector.

    + * + *

    {@link IServerConnector} is an interface for server connector classes who ca connect to an external server + * as a client.

    + * + *

    Of course, {@link IServerConnector} is extended from the {@link ICommunicator}, thus, it also takes full + * charge of network communication and delivers replied message to {@link WebCommunicator.listener listener}'s + * {@link IProtocol.replyData replyData()} method.

    + * + * @handbook Basic Components - IServerConnector + * @author Jeongho Nam + */ + interface IServerConnector extends ICommunicator { + /** + * Callback function for connection completed. + */ + onConnect: Function; + /** + *

    Connect to a server.

    + * + *

    Connects to a server with specified host address and port number. After the connection has + * succeeded, callback function {@link onConnect} is called. Listening data from the connected server also begins. + * Replied messages from the connected server will be converted to {@link Invoke} classes and will be shifted to + * the {@link WebCommunicator.listener listener}'s {@link IProtocol.replyData replyData()} method.

    + * + *

    If the connection fails immediately, either an event is dispatched or an exception is thrown: an error + * event is dispatched if a host was specified, and an exception is thrown if no host was specified. Otherwise, + * the status of the connection is reported by an event. If the socket is already connected, the existing + * connection is closed first.

    + * + * @param ip The name or IP address of the host to connect to. + * If no host is specified, the host that is contacted is the host where the calling file resides. + * If you do not specify a host, use an event listener to determine whether the connection was + * successful. + * @param port The port number to connect to. + */ + connect(ip: string, port: number): void; + } +} +declare namespace samchon.protocol { + class ServerConnector extends Communicator implements IServerConnector { + /** + * @inheritdoc + */ + onConnect: Function; + constructor(listener: IProtocol); + /** + * @inheritdoc + */ + connect(ip: string, port: number): void; + private handle_connect(...arg); + } +} +declare namespace samchon.protocol { + /** + *

    A server connector for web-socket protocol.

    + * + * @author Jeongho Nam + */ + class WebServerConnector extends WebCommunicator implements IServerConnector { + /** + *

    A socket for network I/O.

    + * + *

    Note that, {@link socket} is only used in web-browser environment.

    + */ + private browser_socket; + /** + *

    A driver for server connection.

    + * + *

    Note that, {@link node_client} is only used in NodeJS environment.

    + */ + private node_client; + /** + * @inheritdoc + */ + onConnect: Function; + constructor(listener: IProtocol); + /** + * @inheritdoc + */ + connect(ip: string, port: number, path?: string): void; + /** + * @inheritdoc + */ + close(): void; + /** + * @inheritdoc + */ + sendData(invoke: Invoke): void; + private handle_browser_connect(event); + private handle_browser_message(event); + private handle_node_connect(connection); + } +} +declare namespace samchon.protocol { + class SharedWorkerServerConnector extends SharedWorkerCommunicator implements IServerConnector { + /** + * @inheritdoc + */ + onConnect: Function; + constructor(listener: IProtocol); + connect(jsFile: string): void; + } +} +declare namespace samchon.protocol { + namespace socket { + type socket = any; + type server = any; + type http_server = any; + } + namespace websocket { + type connection = any; + type request = any; + type IMessage = any; + type ICookie = any; + type client = any; + } +} +declare namespace samchon.protocol.external { + /** + *

    An external system driver.

    + * + *

    The {@link ExternalSystem} class represents an external system, connected and interact with this system. + * {@link ExternalSystem} takes full charge of network communication with external system have connected. + * Replied {@link Invoke messages} from the external system is shifted to and processed in, children elements of this + * class, {@link ExternalSystemRole} objects.

    + * + *

    + * + *

    + * + *

    Bridge & Proxy Pattern

    + *

    The {@link ExternalSystem} class can be a bridge for logical proxy. In framework within user, + * which {@link ExternalSystem external system} is connected with {@link ExternalSystemArray this system}, it's not + * important. Only interested in user's perspective is which can be done.

    + * + *

    By using the logical proxy, user dont't need to know which {@link ExternalSystemRole role} is belonged + * to which {@link ExternalSystem system}. Just access to a role directly from {@link ExternalSystemArray.getRole}. + * Sends and receives {@link Invoke} message via the {@link ExternalSystemRole role}.

    + * + *
      + *
    • + * {@link ExternalSystemRole} can be accessed from {@link ExternalSystemArray} directly, without inteferring + * from {@link ExternalSystem}, with {@link ExternalSystemArray.getRole}. + *
    • + *
    • + * When you want to send an {@link Invoke} message to the belonged {@link ExternalSystem system}, just call + * {@link ExternalSystemRole.sendData ExternalSystemRole.sendData()}. Then, the message will be sent to the + * external system. + *
    • + *
    • Those strategy is called Bridge Pattern and Proxy Pattern.
    • + *
    + * + * @author Jeongho Nam + */ + abstract class ExternalSystem extends EntityDequeCollection implements IProtocol { + /** + * A network communicator with external system. + */ + /** + * A network communicator with external system. + */ + protected communicator: ICommunicator; + /** + * The name represents external system have connected. + */ + protected name: string; + /** + * Default Constructor. + */ + constructor(); + /** + * Construct from an IClientDriver object. + * + * @param driver + */ + constructor(driver: IClientDriver); + /** + * Default Destructor. + */ + destructor(): void; + /** + * Identifier of {@link ExternalSystem} is its {@link name}. + */ + key(): string; + /** + * Get {@link name}. + */ + getName(): string; + close(): void; + /** + * Send {@link Invoke} message to external system. + * + * @param invoke An {@link Invoke} message to send. + */ + sendData(invoke: Invoke): void; + /** + * Handle an {@Invoke} message have received. + * + * @param invoke An {@link Invoke} message have received. + */ + replyData(invoke: Invoke): void; + /** + * Tag name of the {@link ExternalSytem} in {@link XML}. + * + * @return system. + */ + TAG(): string; + /** + * Tag name of {@link ExternalSystemRole children elements} belonged to the {@link ExternalSytem} in {@link XML}. + * + * @return role. + */ + CHILD_TAG(): string; + /** + * @inheritdoc + */ + toXML(): library.XML; + /** + * @hidden + */ + private communicator_; + /** + * @hidden + */ + private external_system_array_; + /** + * @hidden + */ + private erasing_; + /** + * @hidden + */ + private external_system_array; + /** + * @hidden + */ + private handle_close(); + } +} +declare namespace samchon.protocol.parallel { + /** + *

    An external parallel system driver.

    + * + * + * + * @author Jeongho Nam + */ + abstract class ParallelSystem extends external.ExternalSystem { + /** + * A manager containing this {@link ParallelSystem} object. + */ + private systemArray; + /** + * A list of {@link Invoke} messages on process. + * + * @see {@link performance} + */ + private progress_list; + /** + * A list of {@link Invoke} messages had processed. + * + * @see {@link performance} + */ + private history_list; + /** + *

    Performance index.

    + * + *

    A performance index that indicates how much fast the connected parallel system is.

    + * + *

    If this {@link ParallelSystem parallel system} hasn't any {@link Invoke} message + * {@link history_list had handled}, then the {@link performance performance index} will be 1, which means + * default and average value between all {@link ParallelSystem} instances (belonged to a same + * {@link ParallelSystemArray} object).

    + * + *

    You can specify this {@link performance} by yourself, but notice that, if the + * {@link performance performance index} is higher then other {@link ParallelSystem} objects, then this + * {@link ParallelSystem parallel system} will ordered to handle more processes than other {@link ParallelSystem} + * objects. Otherwise, the {@link performance performance index) is lower than others, of course, less processes + * will be delivered.

    + * + *

    This {@link performance index} is always re-calculated whenever {@link ParallelSystemArray} calls one of + * them below.

    + * + *
      + *
    • {@link ParallelSystemArray.sendSegmentData ParallelSystemArray.sendSegmentData()}
    • + *
    • {@link ParallelSystemArray.sendPieceData ParallelSystemArray.sendPieceData()}
    • + *
    + * + *

    If this class is a type of {@link DistributedSystem}, a derived class from the {@link ParallelSystem}, + * then {@link DistributedSystemRole.sendData DistributedSystem.sendData()} also cause the re-calculation.

    + * + * @see {@link progress_list}, {@link history_list} + */ + protected performance: number; + /** + * Construct from a {@link ParallelSystemArray}. + * + * @param systemArray A manager containing this {@link ParallelSystem} object. + * @param communicator A communicator who takes full charge of network communication with the external + * parallel system. + */ + constructor(systemArray: ParallelSystemArray, communicator?: ICommunicator); + /** + * Get manager of this object, {@link systemArray}. + * + * @return A manager containing this {@link ParallelSystem} object. + */ + getSystemArray(): ParallelSystemArray; + /** + * Get {@link performant performance index}. + * + * A performance index that indicates how much fast the connected parallel system is. + */ + getPerformance(): number; + /** + * Send an {@link Invoke} message with index of segmentation. + * + * @param invoke An invoke message requesting parallel process. + * @param first Initial piece's index in a section. + * @param last Final piece's index in a section. The ranged used is [first, last), which contains + * all the pieces' indices between first and last, including the piece pointed by index + * first, but not the piece pointed by the index last. + * + * @see {@link ParallelSystemArray.sendPieceData} + */ + private send_piece_data(invoke, first, last); + /** + * + * + * @param xml + * + * @see {@link ParallelSystemArray.notify_end} + */ + private report_invoke_history(xml); + } +} +declare namespace samchon.protocol.distributed { + abstract class DistributedSystem extends parallel.ParallelSystem { + } +} +declare namespace samchon.protocol.external { + /** + *

    An array and manager of {@link ExternalSystem external systems}.

    + * + *

    {@link ExternalSystemArray} is an abstract class contains and manages external system drivers, + * {@link ExternalSystem} objects. You can specify this {@link ExternalSystemArray} to be a server accepting + * {@link ExternalSystem external clients} or a client connecting to {@link IExternalServer external servers}. Even + * both of them is also possible.

    + * + *
      + *
    • A server accepting external clients: {@link IExternalClientArray}
    • + *
    • A client connecting to external servers: {@link IExternalServerArray}
    • + *
    • + * Accepts external clients & Connects to external servers at the same time: + * {@link IExternalServerClientArray} + *
    • + *
    + * + *

    + * + *

    + * + *

    Proxy Pattern

    + *

    The {@link ExternalSystemArray} class can use Proxy Pattern. In framework within user, which + * {@link ExternalSystem external system} is connected with {@link ExternalSystemArray this system}, it's not + * important. Only interested in user's perspective is which can be done.

    + * + *

    By using the logical proxy, user dont't need to know which {@link ExternalSystemRole role} is belonged + * to which {@link ExternalSystem system}. Just access to a role directly from {@link ExternalSystemArray.getRole}. + * Sends and receives {@link Invoke} message via the {@link ExternalSystemRole role}.

    + * + *
      + *
    • + * {@link ExternalSystemRole} can be accessed from {@link ExternalSystemArray} directly, without inteferring + * from {@link ExternalSystem}, with {@link ExternalSystemArray.getRole}. + *
    • + *
    • + * When you want to send an {@link Invoke} message to the belonged {@link ExternalSystem system}, just call + * {@link ExternalSystemRole.sendData ExternalSystemRole.sendData()}. Then, the message will be sent to the + * external system. + *
    • + *
    • Those strategy is called Proxy Pattern.
    • + *
    + * + * @author Jeongho Nam + */ + abstract class ExternalSystemArray extends EntityArrayCollection implements IProtocol { + /** + * Default Constructor. + */ + constructor(); + /** + * @hidden + */ + private handle_system_insert(event); + /** + * @hidden + */ + private handle_system_erase(event); + /** + * @hidden + */ + protected handle_system_close(system: ExternalSystem): void; + /** + * Test whether this system array has the role. + * + * @param name Name, identifier of target {@link ExternalSystemRole role}. + * + * @return Whether the role has or not. + */ + hasRole(name: string): boolean; + /** + * Get a role. + * + * @param name Name, identifier of target {@link ExternalSystemRole role}. + * + * @return The specified role. + */ + getRole(name: string): ExternalSystemRole; + /** + *

    Send an {@link Invoke} message.

    + * + * @param invoke An {@link Invoke} message to send. + */ + sendData(invoke: Invoke): void; + /** + *

    Handle an {@Invoke} message have received.

    + * + * @param invoke An {@link Invoke} message have received. + */ + replyData(invoke: Invoke): void; + /** + * Tag name of the {@link ExternalSytemArray} in {@link XML}. + * + * @return systemArray. + */ + TAG(): string; + /** + * Tag name of {@link ExternalSystem children elements} belonged to the {@link ExternalSytemArray} in {@link XML}. + * + * @return system. + */ + CHILD_TAG(): string; + } +} +declare namespace samchon.protocol.parallel { + /** + *

    A manager containing {@link ParallelSystem} objects.

    + * + * + * + * @author Jeongho Nam + */ + abstract class ParallelSystemArray extends external.ExternalSystemArray { + /** + * @see {@link ParallelSystem.progress_list}, {@link ParallelSystem.history_list} + */ + private history_sequence; + /** + * Default Constructor. + */ + constructor(); + /** + * + * @param invoke An invoke message requesting parallel process. + * @param size Number of pieces. + */ + sendSegmentData(invoke: Invoke, size: number): void; + /** + * + * + * @param invoke An invoke message requesting parallel process. + * @param first Initial piece's index in a section. + * @param last Final piece's index in a section. The ranged used is [first, last), which contains + * all the pieces' indices between first and last, including the piece pointed by index + * first, but not the piece pointed by the index last. + */ + sendPieceData(invoke: Invoke, first: number, last: number): void; + /** + * + * @param history + * + * @return Whether the processes with same uid are all fininsed. + * + * @see {@link ParallelSystem.report_invoke_history}, {@link normalize_performance} + */ + protected notify_end(history: PRInvokeHistory): boolean; + /** + * @see {@link ParallelSystem.performance} + */ + private normalize_performance(); + } +} +declare namespace samchon.protocol.distributed { + abstract class DistributedSystemArray extends parallel.ParallelSystemArray { + protected roles: std.HashMap; + } +} +declare namespace samchon.protocol.external { + /** + *

    A role of an external system.

    + * + *

    The {@link ExternalSystemRole} class represents a role, what to do in an {@link ExternalSystem}. + * Extends this class and writes some methods related to the role.

    + * + *

    + * + *

    + * + *

    Proxy Pattern

    + *

    The {@link ExternalSystemRole} class can be an logical proxy. In framework within user, which + * {@link ExternalSystem external system} is connected with {@link ExternalSystemArray this system}, it's not + * important. Only interested in user's perspective is which can be done.

    + * + *

    By using the logical proxy, user dont't need to know which {@link ExternalSystemRole role} is belonged + * to which {@link ExternalSystem system}. Just access to a role directly from {@link ExternalSystemArray.getRole}. + * Sends and receives {@link Invoke} message via the {@link ExternalSystemRole role}.

    + * + *
      + *
    • + * {@link ExternalSystemRole} can be accessed from {@link ExternalSystemArray} directly, without inteferring + * from {@link ExternalSystem}, with {@link ExternalSystemArray.getRole}. + *
    • + *
    • + * When you want to send an {@link Invoke} message to the belonged {@link ExternalSystem system}, just call + * {@link ExternalSystemRole.sendData ExternalSystemRole.sendData()}. Then, the message will be sent to the + * external system. + *
    • + *
    • Those strategy is called Proxy Pattern.
    • + *
    + * + * @author Jeongho Nam + */ + abstract class ExternalSystemRole extends Entity implements IProtocol { + /** + * An {@link ExternalSystem external system} containing this {@link ExternalSystemRole role}. + */ + private system; + /** + *

    A name, represents and identifies this {@link ExternalSystemRole role}.

    + * + *

    This {@link name} is an identifier represents this {@link ExternalSystemRole role}. This {@link name} is + * used in {@link ExternalSystemArray.getRole} and {@link ExternalSystem.get}, as a key elements. Thus, this + * {@link name} should be unique in an {@link ExternalSystemArray}. + */ + private name; + /** + * Constructor from a system. + * + * @param system An external system containing this role. + */ + constructor(system: ExternalSystem); + /** + * Identifier of {@link ExternalSystemRole} is its {@link name}. + */ + key(): string; + /** + * Get external system, this role is belonged to. + */ + getSystem(): ExternalSystem; + /** + * Get name, who represents and identifies this role. + */ + getName(): string; + /** + * Send an {@link Invoke} message to the external system via {@link system}. + * + * @param invoke An {@link Invoke} message to send to the external system. + */ + sendData(invoke: Invoke): void; + /** + *

    Handle replied {@link Invoke message} from the {@link system external system} belonged to.

    + * + *

    This {@link replyData replyData()} will call a member method named following {@link Invoke.listener}. + * in the invoke.

    + * + * @param invoke An {@link Invoke} message received from the {@link system external system}. + */ + replyData(invoke: Invoke): void; + /** + * Tag name of the {@link ExternalSytemRole} in {@link XML}. + * + * @return role. + */ + TAG(): string; + } +} +declare namespace samchon.protocol.distributed { + abstract class DistributedSystemRole extends external.ExternalSystemRole { + private systems; + } +} +declare namespace samchon.protocol.external { + /** + *

    An interface for an {@link ExternalSystemArray} accepts {@link ExternalSystem external clients} as a + * {@link IServer server}.

    + * + *

    The easiest way to defining an {@link ExternalSystemArray} who opens server and accepts + * {@link ExternalSystem external clients} is to extending one of below, who are derived from this interface + * {@link IExternalClientArray}. However, if you can't specify an {@link ExternalSystemArray} to be whether server or + * client, then make a class (let's name it as BaseSystemArray) extending {@link ExternalSystemArray} and make + * a new class (now, I name it BaseClientArray) extending BaseSystemArray and implementing this + * interface {@link IExternalClientArray}. Define the BaseClientArray following those codes on below: + * + *

    + * + * @author Jeongho Nam + */ + interface IExternalClientArray extends ExternalSystemArray, IServer { + } + /** + *

    An {@link ExternalSystemArray} acceepts {@link ExternalSystem external clients} as a {@link IServer server}.

    + * + *

    {@link ExternalServerArray} is an abstract class contains, manages and accepts external server drivers, + * {@link IExternalServer} objects, as a {@link IServer server}.

    + * + *

    + * + *

    + * + *

    Proxy Pattern

    + *

    The {@link ExternalSystemArray} class can use Proxy Pattern. In framework within user, which + * {@link ExternalSystem external system} is connected with {@link ExternalSystemArray this system}, it's not + * important. Only interested in user's perspective is which can be done.

    + * + *

    By using the logical proxy, user dont't need to know which {@link ExternalSystemRole role} is belonged + * to which {@link ExternalSystem system}. Just access to a role directly from {@link ExternalSystemArray.getRole}. + * Sends and receives {@link Invoke} message via the {@link ExternalSystemRole role}.

    + * + *
      + *
    • + * {@link ExternalSystemRole} can be accessed from {@link ExternalSystemArray} directly, without inteferring + * from {@link ExternalSystem}, with {@link ExternalSystemArray.getRole}. + *
    • + *
    • + * When you want to send an {@link Invoke} message to the belonged {@link ExternalSystem system}, just call + * {@link ExternalSystemRole.sendData ExternalSystemRole.sendData()}. Then, the message will be sent to the + * external system. + *
    • + *
    • Those strategy is called Proxy Pattern.
    • + *
    + * + * @author Jeongho Nam + */ + abstract class ExternalClientArray extends ExternalSystemArray implements IExternalClientArray { + /** + * A subrogator of {@link IServer server}'s role instead of this {@link ExternalClientArray}. + */ + private server_base; + /** + * Default Constructor. + */ + constructor(); + /** + *

    Factory method creating {@link IServerBase} object.

    + * + *

    This method {@link createServerBase createServerBase()} determines which protocol is used in this server, + * {@link ExternalClientArray}. If the protocol is determined, then {@link ExternalSystem external clients} who + * may connect to {@link ExternalClientArray this server} must follow the specified protocol.

    + * + *

    Creates and returns one of them:

    + *
      + *
    • {@link ServerBase}
    • + *
    • {@link WebServerBase}
    • + *
    • {@link SharedWorkerServerBase}
    • + *
    + * + * @return A new {@link IServerBase} object. + */ + protected abstract createServerBase(): IServerBase; + addClient(driver: IClientDriver): void; + /** + * This method is deprecated. Don't use and override this. + * + * @return null. + */ + protected createChild(xml: library.XML): ExternalSystem; + /** + * Factory method creating {@link ExternalSystem} object. + * + * @param driver A communicator with connected client. + * @return A newly created {@link ExternalSystem} object. + */ + protected abstract createExternalClient(driver: IClientDriver): ExternalSystem; + /** + * @inheritdoc + */ + open(port: number): void; + /** + * @inheritdoc + */ + close(): void; + } +} +declare namespace samchon.protocol.external { + /** + *

    An interface for an external server driver.

    + * + *

    The easiest way to defining an external server driver is to extending one of below, who are derived from this + * interface {@link IExternalServer}. However, if you've to interact with an external system who can be both server + * and client, then make a class (let's name it as BaseSystem) extending {@link ExternalSystem} and make a + * new class (now, I name it BaseServer) extending BaseSystem and implementing this interface + * {@link IExternalServer}. Define the BaseServer following those codes on below: + * + *

    + * + * @author Jeongho Nam + */ + interface IExternalServer extends ExternalSystem { + /** + * Connect to the external system. + */ + connect(): void; + /** + * Get ip address. + */ + getIP(): string; + /** + * Get port number. + */ + getPort(): number; + } + /** + *

    An external server driver.

    + * + *

    The {@link ExternalServer} class represents an external server, connected and interact with this system. + * {@link ExternalServer} takes full charge of network communication with external server have connected. + * Replied {@link Invoke messages} from the external system is shifted to and processed in, children elements of this + * class, {@link ExternalSystemRole} objects.

    + * + *

    + * + *

    + * + *

    Bridge & Proxy Pattern

    + *

    The {@link ExternalSystem} class can be a bridge for logical proxy. In framework within user, + * which {@link ExternalSystem external system} is connected with {@link ExternalSystemArray this system}, it's not + * important. Only interested in user's perspective is which can be done.

    + * + *

    By using the logical proxy, user dont't need to know which {@link ExternalSystemRole role} is belonged + * to which {@link ExternalSystem system}. Just access to a role directly from {@link ExternalSystemArray.getRole}. + * Sends and receives {@link Invoke} message via the {@link ExternalSystemRole role}.

    + * + *
      + *
    • + * {@link ExternalSystemRole} can be accessed from {@link ExternalSystemArray} directly, without inteferring + * from {@link ExternalSystem}, with {@link ExternalSystemArray.getRole}. + *
    • + *
    • + * When you want to send an {@link Invoke} message to the belonged {@link ExternalSystem system}, just call + * {@link ExternalSystemRole.sendData ExternalSystemRole.sendData()}. Then, the message will be sent to the + * external system. + *
    • + *
    • Those strategy is called Bridge Pattern and Proxy Pattern.
    • + *
    + * + * @author Jeongho Nam + */ + abstract class ExternalServer extends ExternalSystem implements IExternalServer { + /** + * IP address of target external system to connect. + */ + protected ip: string; + /** + * Port number of target external system to connect. + */ + protected port: number; + /** + * Default Constructor. + */ + constructor(); + /** + * Factory method creating server connector. + */ + protected abstract createServerConnector(): IServerConnector; + /** + * @inheritdoc + */ + connect(): void; + /** + * @inheritdoc + */ + getIP(): string; + /** + * @inheritdoc + */ + getPort(): number; + } +} +declare namespace samchon.protocol.external { + /** + *

    An interface for an {@link ExternalSystemArray} connects to {@link IExternalServer external servers} as a + * client.

    + * + *

    The easiest way to defining an {@link ExternalSystemArray} who connects to + * {@link IExternalServer external servers} is to extending one of below, who are derived from this interface + * {@link IExternalServerArray}. However, if you can't specify an {@link ExternalSystemArray} to be whether server or + * client, then make a class (let's name it as BaseSystemArray) extending {@link ExternalSystemArray} and make + * a new class (now, I name it BaseServerArray) extending BaseSystemArray and implementing this + * interface {@link IExternalServerArray}. Define the BaseServerArray following those codes on below: + * + *

    + * + * @author Jeongho Nam + */ + interface IExternalServerArray extends ExternalSystemArray { + /** + *

    Connect to {@link IExternalServer external servers}.

    + * + *

    This method calls children elements' method {@link IExternalServer.connect} gradually.

    + */ + connect(): void; + } + /** + *

    An {@link ExternalSystemArray} connecting to {@link IExternalServer external servers} as a client.

    + * + *

    {@link ExternalServerArray} is an abstract class contains, manages and connects to external server drivers, + * {@link IExternalServer} objects, as a client.

    + * + *

    + * + *

    + * + *

    Proxy Pattern

    + *

    The {@link ExternalSystemArray} class can use Proxy Pattern. In framework within user, which + * {@link ExternalSystem external system} is connected with {@link ExternalSystemArray this system}, it's not + * important. Only interested in user's perspective is which can be done.

    + * + *

    By using the logical proxy, user dont't need to know which {@link ExternalSystemRole role} is belonged + * to which {@link ExternalSystem system}. Just access to a role directly from {@link ExternalSystemArray.getRole}. + * Sends and receives {@link Invoke} message via the {@link ExternalSystemRole role}.

    + * + *
      + *
    • + * {@link ExternalSystemRole} can be accessed from {@link ExternalSystemArray} directly, without inteferring + * from {@link ExternalSystem}, with {@link ExternalSystemArray.getRole}. + *
    • + *
    • + * When you want to send an {@link Invoke} message to the belonged {@link ExternalSystem system}, just call + * {@link ExternalSystemRole.sendData ExternalSystemRole.sendData()}. Then, the message will be sent to the + * external system. + *
    • + *
    • Those strategy is called Proxy Pattern.
    • + *
    + * + * @author Jeongho Nam + */ + abstract class ExternalServerArray extends ExternalSystemArray { + /** + * Default Constructor. + */ + constructor(); + /** + * @inheritdoc + */ + connect(): void; + } +} +declare namespace samchon.protocol.external { + /** + *

    An interface for an {@link ExternalSystemArray} accepts {@link ExternalSystem external clients} as a + * {@link IServer server} and connects to {@link IExternalServer} as client, at the same time.

    + * + *

    The easiest way to defining an {@link IExternalServerClientArray} who opens server, accepts + * {@link ExternalSystem external clients} and connects to {@link IExternalServer external servers} is to extending + * one of below, who are derived from this interface {@link IExternalServerClientArray}. However, if you can't + * specify an {@link ExternalSystemArray} to be whether server or client or even can both them, then make a class + * (let's name it as BaseSystemArray) extending {@link ExternalSystemArray} and make a new class (now, I name + * it BaseServerClientArray) extending BaseSystemArray and implementing this interface + * {@link IExternalServerClientArray}. Define the BaseServerClientArray following those codes on below: + * + *

    + * + * @author Jeongho Nam + */ + interface IExternalServerClientArray extends IExternalServerArray, IExternalClientArray { + } + /** + *

    An {@link ExternalSystemArray} connecting to {@link IExternalServer external servers} as a client and + * accepts {@link ExternalSystem external clients} as a {@link IServer server}.

    + * + *

    {@link ExternalServerArray} is an abstract class contains, manages and connects to external server drivers, + * {@link IExternalServer} objects and accepts external client drivers {@link ExternalSyste} obejcts as a + * client and a {@link IServer server} at the same time.

    + * + *

    + * + *

    + * + *

    Proxy Pattern

    + *

    The {@link ExternalSystemArray} class can use Proxy Pattern. In framework within user, which + * {@link ExternalSystem external system} is connected with {@link ExternalSystemArray this system}, it's not + * important. Only interested in user's perspective is which can be done.

    + * + *

    By using the logical proxy, user dont't need to know which {@link ExternalSystemRole role} is belonged + * to which {@link ExternalSystem system}. Just access to a role directly from {@link ExternalSystemArray.getRole}. + * Sends and receives {@link Invoke} message via the {@link ExternalSystemRole role}.

    + * + *
      + *
    • + * {@link ExternalSystemRole} can be accessed from {@link ExternalSystemArray} directly, without inteferring + * from {@link ExternalSystem}, with {@link ExternalSystemArray.getRole}. + *
    • + *
    • + * When you want to send an {@link Invoke} message to the belonged {@link ExternalSystem system}, just call + * {@link ExternalSystemRole.sendData ExternalSystemRole.sendData()}. Then, the message will be sent to the + * external system. + *
    • + *
    • Those strategy is called Proxy Pattern.
    • + *
    + * + * @author Jeongho Nam + */ + abstract class ExternalServerClientArray extends ExternalClientArray implements IExternalServerClientArray { + /** + * Default Constructor. + */ + constructor(); + /** + *

    Factory method of a child Entity.

    + * + *

    This method is migrated to {@link createExternalServer createExternalServer()}. Override the + * {@link createExternalServer createExternalServer()}.

    + * + * @param xml An {@link XML} object represents child element, so that can identify the type of child to create. + * + * @return A new child Entity via {@link createExternalServer createExternalServer()}. + */ + protected createChild(xml: library.XML): ExternalSystem; + /** + * Factory method creating an {@link IExternalServer} object. + * + * @param xml An {@link XML} object represents child element, so that can identify the type of child to create. + * + * @return A newly created {@link IExternalServer} object. + */ + protected abstract createExternalServer(xml: library.XML): IExternalServer; + /** + * @inheritdoc + */ + connect(): void; + } +} +declare namespace samchon.protocol.slave { + abstract class SlaveSystem extends external.ExternalSystem { + /** + * Default Constructor. + */ + constructor(); replyData(invoke: Invoke): void; } } +declare namespace samchon.protocol.external { + abstract class MediatorSystem extends slave.SlaveSystem { + private system_array; + private progress_list; + constructor(systemArray: ExternalSystemArray); + abstract start(): void; + /** + * @hidden + */ + protected createChild(xml: library.XML): ExternalSystemRole; + private notify_end(uid); + replyData(invoke: protocol.Invoke): void; + } +} +declare namespace samchon.protocol.external { + class MediatorServer extends MediatorSystem implements IServer { + private server_base; + private port; + constructor(systemArray: ExternalSystemArray, port: number); + protected createServerBase(): IServerBase; + addClient(driver: IClientDriver): void; + start(): void; + open(port: number): void; + close(): void; + } + class MediatorWebServer extends MediatorServer { + protected createServerBase(): IServerBase; + } + class MediatorSharedWorkerServer extends MediatorServer { + protected createServerBase(): IServerBase; + } +} +declare namespace samchon.protocol.external { + class MediatorClient extends MediatorSystem implements IExternalServer { + protected ip: string; + protected port: number; + constructor(systemArray: ExternalSystemArray, ip: string, port: number); + protected createServerConnector(): IServerConnector; + getIP(): string; + getPort(): number; + start(): void; + connect(): void; + } + class MediatorWebClient extends MediatorClient { + /** + * @inheritdoc + */ + protected createServerConnector(): IServerConnector; + } + class MediatorSharedWorkerClient extends MediatorClient { + /** + * @inheritdoc + */ + protected createServerConnector(): IServerConnector; + } +} +declare namespace samchon.protocol.parallel { + class PRInvokeHistory extends InvokeHistory { + /** + * Index number of initial piece. + */ + private first; + /** + * Index number of final piece. + */ + private last; + /** + * Default Constructor. + */ + constructor(); + /** + * Construct from an Invoke message. + * + * @param invoke + */ + constructor(invoke: Invoke); + getFirst(): number; + getLast(): number; + /** + * Compute number of allocated pieces. + */ + computeSize(): number; + } +} +declare namespace samchon.protocol.parallel { + abstract class ParallelClientArray extends ParallelSystemArray implements external.IExternalClientArray { + /** + * A subrogator of {@link IServer server}'s role instead of this {@link ExternalClientArray}. + */ + private server_base; + /** + * Default Constructor. + */ + constructor(); + /** + *

    Factory method creating {@link IServerBase} object.

    + * + *

    This method {@link createServerBase createServerBase()} determines which protocol is used in this server, + * {@link ExternalClientArray}. If the protocol is determined, then {@link ExternalSystem external clients} who + * may connect to {@link ExternalClientArray this server} must follow the specified protocol.

    + * + *

    Creates and returns one of them:

    + *
      + *
    • {@link ServerBase}
    • + *
    • {@link WebServerBase}
    • + *
    • {@link SharedWorkerServerBase}
    • + *
    + * + * @return A new {@link IServerBase} object. + */ + protected abstract createServerBase(): IServerBase; + addClient(driver: IClientDriver): void; + protected createChild(xml: library.XML): ParallelSystem; + protected abstract createExternalClient(driver: IClientDriver): ParallelSystem; + /** + * @inheritdoc + */ + open(port: number): void; + /** + * @inheritdoc + */ + close(): void; + } +} +declare namespace samchon.protocol.parallel { + abstract class ParallelSystemArrayMediator extends ParallelSystemArray { + protected mediator: external.MediatorSystem; + /** + * Default Constructor. + */ + constructor(); + protected abstract createMediator(): external.MediatorSystem; + protected start_mediator(): void; + sendData(invoke: protocol.Invoke): void; + sendPieceData(invoke: protocol.Invoke, first: number, last: number): void; + protected notify_end(history: PRInvokeHistory): boolean; + } +} +declare namespace samchon.protocol.parallel { + abstract class ParallelClientArrayMediator extends ParallelSystemArrayMediator implements external.IExternalClientArray { + /** + * A subrogator of {@link IServer server}'s role instead of this {@link ExternalClientArray}. + */ + private server_base; + /** + * Default Constructor. + */ + constructor(); + /** + *

    Factory method creating {@link IServerBase} object.

    + * + *

    This method {@link createServerBase createServerBase()} determines which protocol is used in this server, + * {@link ExternalClientArray}. If the protocol is determined, then {@link ExternalSystem external clients} who + * may connect to {@link ExternalClientArray this server} must follow the specified protocol.

    + * + *

    Creates and returns one of them:

    + *
      + *
    • {@link ServerBase}
    • + *
    • {@link WebServerBase}
    • + *
    • {@link SharedWorkerServerBase}
    • + *
    + * + * @return A new {@link IServerBase} object. + */ + protected abstract createServerBase(): IServerBase; + addClient(driver: IClientDriver): void; + protected createChild(xml: library.XML): ParallelSystem; + protected abstract createExternalClient(driver: IClientDriver): ParallelSystem; + /** + * @inheritdoc + */ + open(port: number): void; + /** + * @inheritdoc + */ + close(): void; + } +} +declare namespace samchon.protocol.parallel { + interface IParallelServer extends ParallelSystem, external.IExternalServer { + } + abstract class ParallelServer extends ParallelSystem implements IParallelServer { + protected ip: string; + protected port: number; + constructor(systemArray: ParallelSystemArray); + protected abstract createServerConnector(): IServerConnector; + connect(): void; + getIP(): string; + getPort(): number; + } +} +declare namespace samchon.protocol.parallel { + abstract class ParallelServerArray extends ParallelSystemArray implements external.IExternalServerArray { + constructor(); + connect(): void; + } +} +declare namespace samchon.protocol.parallel { + abstract class ParallelServerArrayMediator extends ParallelSystemArrayMediator implements external.IExternalServerArray { + constructor(); + connect(): void; + } +} +declare namespace samchon.protocol.parallel { + abstract class ParallelServerClientArray extends ParallelClientArray implements external.IExternalServerClientArray { + /** + * Default Constructor. + */ + constructor(); + protected createChild(xml: library.XML): ParallelSystem; + protected abstract createExternalServer(xml: library.XML): IParallelServer; + connect(): void; + } +} +declare namespace samchon.protocol.parallel { + abstract class ParallelServerClientArrayMediator extends ParallelClientArrayMediator implements external.IExternalServerClientArray { + /** + * Default Constructor. + */ + constructor(); + protected createChild(xml: library.XML): ParallelSystem; + protected abstract createExternalServer(xml: library.XML): IParallelServer; + /** + * @inheritdoc + */ + connect(): void; + } +} +declare namespace samchon.protocol.service { + abstract class Client implements protocol.IProtocol { + private user; + private service; + private driver; + private no; + /** + * Construct from an User and WebClientDriver. + */ + constructor(user: User, driver: WebClientDriver); + protected abstract createService(path: string): Service; + close(): void; + getUser(): User; + getService(): Service; + sendData(invoke: protocol.Invoke): void; + replyData(invoke: protocol.Invoke): void; + protected changeService(path: string): void; + } +} +declare namespace samchon.protocol.service { + abstract class Server extends protocol.WebServer implements IProtocol { + private session_map; + private account_map; + /** + * Default Constructor. + */ + constructor(); + /** + * Factory method creating {@link User} object. + * + * @return A newly created {@link User} object. + */ + protected abstract createUser(): User; + has(account: string): boolean; + get(account: string): User; + sendData(invoke: protocol.Invoke): void; + replyData(invoke: protocol.Invoke): void; + addClient(driver: WebClientDriver): void; + private erase_user(user); + } +} +declare namespace samchon.protocol.service { + abstract class Service implements protocol.IProtocol { + private client; + private path; + /** + * Default Constructor. + */ + constructor(client: Client, path: string); + destructor(): void; + /** + * Get client. + */ + getClient(): Client; + /** + * Get path. + */ + getPath(): string; + sendData(invoke: protocol.Invoke): void; + replyData(invoke: protocol.Invoke): void; + } +} +declare namespace samchon.protocol.service { + abstract class User extends collection.HashMapCollection implements protocol.IProtocol { + private server; + private session_id; + private sequence; + private account_id; + private authority; + /** + * Construct from a Server. + */ + constructor(server: Server); + protected abstract createClient(driver: WebClientDriver): Client; + private handle_erase_client(event); + getServer(): Server; + getAccountID(): string; + getAuthority(): number; + setAccount(id: string, authority: number): void; + sendData(invoke: protocol.Invoke): void; + replyData(invoke: protocol.Invoke): void; + } +} +declare namespace samchon.protocol.slave { + abstract class SlaveClient extends SlaveSystem { + constructor(); + protected abstract createServerConnector(): IServerConnector; + connect(ip: string, port: number): void; + } +} +declare namespace samchon.protocol.slave { + abstract class SlaveServer extends SlaveSystem implements IServer { + private server_base; + constructor(); + protected abstract createServerBase(): IServerBase; + addClient(driver: IClientDriver): void; + open(port: number): void; + close(): void; + } +} diff --git a/typescript-stl/typescript-stl-tests.ts b/typescript-stl/typescript-stl-tests.ts index cc684cde7e..d83a9ffc5a 100644 --- a/typescript-stl/typescript-stl-tests.ts +++ b/typescript-stl/typescript-stl-tests.ts @@ -1,4 +1,4 @@ /// import std = require("typescript-stl"); -std.example.test_all(); \ No newline at end of file +console.log(std); \ No newline at end of file diff --git a/typescript-stl/typescript-stl.d.ts b/typescript-stl/typescript-stl.d.ts index a0f92b88b6..9e491ff258 100644 --- a/typescript-stl/typescript-stl.d.ts +++ b/typescript-stl/typescript-stl.d.ts @@ -1,4 +1,4 @@ -// Type definitions for TypeScript-STL v1.0.0-rc.3 +// Type definitions for TypeScript-STL v1.0.0 // Project: https://github.com/samchon/typescript-stl // Definitions by: Jeongho Nam // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -117,13 +117,6 @@ declare namespace std { */ declare namespace std.base { } -/** - * Examples for supporting developers who use STL library. - * - * @author Jeongho Nam - */ -declare namespace std.example { -} declare namespace std { /** *

    Apply function to range.

    @@ -2751,8 +2744,8 @@ declare namespace std.base { /** *

    An abstract container.

    * - *

    - * + *

    + * *

    * *

    Container properties

    @@ -2872,8 +2865,8 @@ declare namespace std { *

    There is not a single type of {@link Iterator bidirectional iterator}: {@link IContainer Each container} * may define its own specific iterator type able to iterate through it and access its elements.

    * - *

    - * + *

    + * *

    * * @reference http://www.cplusplus.com/reference/iterator/BidirectionalIterator @@ -2958,18 +2951,45 @@ declare namespace std { * first element in a range is reversed, the reversed iterator points to the element before the first element (this * would be the past-the-end element of the reversed range).

    * - *

    - * + *

    + * *

    * * @reference http://www.cplusplus.com/reference/iterator/reverse_iterator * @author Jeongho Nam */ abstract class ReverseIterator, This extends ReverseIterator> extends Iterator { + /** + * @hidden + */ protected base_: Base; + /** + * Construct from base iterator. + * + * @param base A reference of the base iterator, which iterates in the opposite direction. + */ constructor(base: Base); + /** + *

    Return base iterator.

    + * + *

    Return a reference of the base iteraotr.

    + * + *

    The base iterator is an iterator of the same type as the one used to construct the {@link ReverseIterator}, + * but pointing to the element next to the one the {@link ReverseIterator} is currently pointing to + * (a {@link ReverseIterator} has always an offset of -1 with respect to its base iterator). + * + * @return A reference of the base iterator, which iterates in the opposite direction. + */ base(): Base; + /** + * @hidden + */ protected abstract create_neighbor(): This; + /** + *

    Get value of the iterator is pointing.

    + * + * @return A value of the reverse iterator. + */ value: T; /** * @inheritdoc @@ -3194,8 +3214,8 @@ declare namespace std { * the end, {@link Deque Deques} perform worse and have less consistent iterators and references than * {@link List Lists}.

    * - *

    - * + *

    + * *

    * *

    Container properties

    @@ -3217,66 +3237,27 @@ declare namespace std { */ class Deque extends base.Container implements base.IArrayContainer, base.IDequeContainer { /** - *

    Row size of the {@link matrix_ matrix} which contains elements.

    - * - *

    Note that the {@link ROW} affects on time complexity of accessing and inserting element. - * Accessing element is {@link ROW} times slower than ordinary {@link Vector} and inserting element - * in middle position is {@link ROW} times faster than ordinary {@link Vector}.

    - * - *

    When the {@link ROW} returns 8, time complexity of accessing element is O(8) and inserting - * element in middle position is O(N/8). ({@link Vector}'s time complexity of accessement is O(1) - * and inserting element is O(N)).

    + * @hidden */ private static ROW; /** - *

    Minimum {@link capacity}.

    - * - *

    Although a {@link Deque} has few elements, even no element is belonged to, the {@link Deque} - * keeps the minimum {@link capacity} at least.

    + * @hidden */ private static MIN_CAPACITY; /** - *

    A matrix containing elements.

    - * - *

    This {@link matrix_} is the biggest difference one between {@link Vector} and {@link Deque}. - * Its number of rows follows {@link ROW} and number of columns follows {@link get_col_size} which - * returns divide of {@link capacity} and {@link ROW}.

    - * - * By separating segment of elements (segment: row, elements in a segment: col), {@link Deque} takes - * advantage of time complexity on inserting element in middle position. {@link Deque} is {@link ROW} - * times faster than {@link Vector} when inserting elements in middle position.

    - * - *

    However, separating segment of elements from matrix, {@link Deque} also takes disadvantage of - * time complexity on accessing element. {@link Deque} is {@link ROW} times slower than {@link Vector} - * when accessing element.

    + * @hidden */ private matrix_; /** - * Number of elements in the {@link Deque}. + * @hidden */ private size_; /** - *

    Size of allocated storage capacity.

    - * - *

    The {@link capacity_ capacity} is size of the storage space currently allocated for the - * {@link Deque container}, expressed in terms of elements.

    - * - *

    This {@link capacity_ capacity} is not necessarily equal to the {@link Deque container} - * {@link size}. It can be equal or greater, with the extra space allowing to accommodate for growth - * without the need to reallocate on each insertion.

    - * - *

    Notice that this {@link capacity_ capacity} does not suppose a limit on the {@link size} of - * the {@link Deque container}. When this {@link capacity} is exhausted and more is needed, it is - * automatically expanded by the {@link Deque container} (reallocating it storage space). - * The theoretical limit on the {@link size} of a {@link Deque container} is given by member - * {@link max_size}.

    - * - *

    The {@link capacity_ capacity} of a {@link Deque container} can be explicitly altered by - * calling member {@link Deque.reserve}.

    + * @hidden */ private capacity_; /** - * Get column size; {@link capacity_ capacity} / {@link ROW row}. + * @hidden */ private get_col_size(); /** @@ -3480,8 +3461,8 @@ declare namespace std { /** *

    An iterator of {@link Deque}.

    * - *

    - * + *

    + * *

    * * @author Jeongho Nam @@ -3509,6 +3490,11 @@ declare namespace std { /** * @inheritdoc */ + /** + * Set value of the iterator is pointing to. + * + * @param val Value to set. + */ value: T; /** * @inheritdoc @@ -3552,8 +3538,8 @@ declare namespace std { /** *

    A reverse-iterator of Deque.

    * - *

    - * + *

    + * *

    * * @param Type of the elements. @@ -3561,13 +3547,20 @@ declare namespace std { * @author Jeongho Nam */ class DequeReverseIterator extends ReverseIterator, DequeReverseIterator> implements base.IArrayIterator { + /** + * Construct from base iterator. + * + * @param base A reference of the base iterator, which iterates in the opposite direction. + */ constructor(base: DequeIterator); /** - * @inheritdoc + * @hidden */ protected create_neighbor(): DequeReverseIterator; /** - * Set value. + * Set value of the iterator is pointing to. + * + * @param val Value to set. */ value: T; /** @@ -3629,8 +3622,8 @@ declare namespace std { *

    All objects thrown by components of the standard library are derived from this class. * Therefore, all standard exceptions can be caught by catching this type by reference.

    * - *

    - *

    + *

    + *

    * * @reference http://www.cplusplus.com/reference/exception/exception * @author Jeongho Nam @@ -3678,8 +3671,8 @@ declare namespace std { * *

    It is used as a base class for several logical error exceptions.

    * - *

    - *

    + *

    + *

    * * @reference http://www.cplusplus.com/reference/stdexcept/logic_error * @author Jeongho Nam @@ -3704,8 +3697,8 @@ declare namespace std { *

    No component of the standard library throws exceptions of this type. It is designed as a standard * exception to be thrown by programs.

    * - *

    - *

    + *

    + *

    * * @reference http://www.cplusplus.com/reference/stdexcept/domain_error * @author Jeongho Nam @@ -3726,8 +3719,8 @@ declare namespace std { *

    It is a standard exception that can be thrown by programs. Some components of the standard library * also throw exceptions of this type to signal invalid arguments.

    * - *

    - *

    + *

    + *

    * * @reference http://www.cplusplus.com/reference/stdexcept/invalid_argument * @author Jeongho Nam @@ -3748,8 +3741,8 @@ declare namespace std { *

    It is a standard exception that can be thrown by programs. Some components of the standard library, * such as vector and string also throw exceptions of this type to signal errors resizing.

    * - *

    - *

    + *

    + *

    * * @reference http://www.cplusplus.com/reference/stdexcept/length_error * @author Jeongho Nam @@ -3771,8 +3764,8 @@ declare namespace std { * such as vector, deque, string and bitset also throw exceptions of this type to signal arguments * out of range.

    * - *

    - *

    + *

    + *

    * * @reference http://www.cplusplus.com/reference/stdexcept/out_of_range * @author Jeongho Nam @@ -3793,8 +3786,8 @@ declare namespace std { * *

    It is used as a base class for several runtime error exceptions.

    * - *

    - *

    + *

    + *

    * * @reference http://www.cplusplus.com/reference/stdexcept/runtime_error * @author Jeongho Nam @@ -3815,8 +3808,8 @@ declare namespace std { *

    It is a standard exception that can be thrown by programs. Some components of the standard library * also throw exceptions of this type to signal range errors.

    * - *

    - *

    + *

    + *

    * * @reference http://www.cplusplus.com/reference/stdexcept/overflow_error * @author Jeongho Nam @@ -3837,8 +3830,8 @@ declare namespace std { *

    No component of the standard library throws exceptions of this type. It is designed as a standard * exception to be thrown by programs.

    * - *

    - *

    + *

    + *

    * * @reference http://www.cplusplus.com/reference/stdexcept/underflow_error * @author Jeongho Nam @@ -3860,8 +3853,8 @@ declare namespace std { *

    It is a standard exception that can be thrown by programs. Some components of the standard library * also throw exceptions of this type to signal range errors.

    * - *

    - *

    + *

    + *

    * * @reference http://www.cplusplus.com/reference/stdexcept/range_error * @author Jeongho Nam @@ -4422,8 +4415,8 @@ declare namespace std.base { * {@link List} and registering {@link ListIterator iterators} of the {@link data_ list container} to an index * table like {@link RBTree tree} or {@link HashBuckets hash-table}.

    * - *

    - *

    + *

    + *

    * *

    Container properties

    *
    @@ -4820,8 +4813,8 @@ declare namespace std { /** *

    An iterator of {@link MapContainer map container}.

    * - *

    - *

    + *

    + *

    * * @author Jeongho Nam */ @@ -4891,13 +4884,21 @@ declare namespace std { /** *

    A reverse-iterator of {@link MapContainer map container}.

    * - *

    - *

    + *

    + *

    * * @author Jeongho Nam */ class MapReverseIterator extends ReverseIterator, MapIterator, MapReverseIterator> { + /** + * Construct from base iterator. + * + * @param base A reference of the base iterator, which iterates in the opposite direction. + */ constructor(base: MapIterator); + /** + * @hidden + */ protected create_neighbor(): MapReverseIterator; /** * Get first, key element. @@ -4931,8 +4932,8 @@ declare namespace std.base { * {@link List} and registering {@link ListIterator iterators} of the {@link data_ list container} to an index * table like {@link RBTree tree} or {@link HashBuckets hash-table}.

    * - *

    - *

    + *

    + *

    * *

    Container properties

    *
    @@ -5198,8 +5199,8 @@ declare namespace std.base { * {@link List} and registering {@link ListIterator iterators} of the {@link data_ list container} to an index * table like {@link RBTree tree} or {@link HashBuckets hash-table}.

    * - *

    - *

    + *

    + *

    * *

    Container properties

    *
    @@ -5311,8 +5312,8 @@ declare namespace std { *

    {@link HashMap} containers are faster than {@link TreeMap} containers to access individual elements by their * key, although they are generally less efficient for range iteration through a subset of their elements.

    * - *

    - * + *

    + * *

    * *

    Container properties

    @@ -5342,6 +5343,9 @@ declare namespace std { * @author Jeongho Nam */ class HashMap extends base.UniqueMap implements base.IHashMap { + /** + * @hidden + */ private hash_buckets_; /** * @hidden @@ -5473,8 +5477,8 @@ declare namespace std { *

    Elements with equivalent keys are grouped together in the same bucket and in such a way that * an iterator can iterate through all of them. Iterators in the container are doubly linked iterators.

    * - *

    - * + *

    + * *

    * *

    Container properties

    @@ -5505,7 +5509,7 @@ declare namespace std { */ class HashMultiMap extends base.MultiMap { /** - * + * @hidden */ private hash_buckets_; /** @@ -5633,8 +5637,8 @@ declare namespace std.base { * {@link List} and registering {@link ListIterator iterators} of the {@link data_ list container} to an index * table like {@link RBTree tree} or {@link HashBuckets hash-table}.

    * - *

    - *

    + *

    + *

    * *

    Container properties

    *
    @@ -5910,8 +5914,8 @@ declare namespace std { /** *

    An iterator of a Set.

    * - *

    - *

    + *

    + *

    * * @author Jeongho Nam */ @@ -5969,146 +5973,26 @@ declare namespace std { /** *

    A reverse-iterator of Set.

    * - *

    - *

    + *

    + *

    * * @param Type of the elements. * * @author Jeongho Nam */ class SetReverseIterator extends ReverseIterator, SetReverseIterator> { + /** + * Construct from base iterator. + * + * @param base A reference of the base iterator, which iterates in the opposite direction. + */ constructor(base: SetIterator); /** - * @inheritdoc + * @hidden */ protected create_neighbor(): SetReverseIterator; } } -declare namespace std.base { - /** - *

    An abstract set.

    - * - *

    {@link SetContainer SetContainers} are containers that store elements allowing fast retrieval of - * individual elements based on their value.

    - * - *

    In an {@link SetContainer}, the value of an element is at the same time its key, used to uniquely - * identify it. Keys are immutable, therefore, the elements in an {@link SetContainer} cannot be modified - * once in the container - they can be inserted and removed, though.

    - * - *

    {@link SetContainer} stores elements, keeps sequence and enables indexing by inserting elements into a - * {@link List} and registering {@link ListIterator iterators} of the {@link data_ list container} to an index - * table like {@link RBTree tree} or {@link HashBuckets hash-table}.

    - * - *

    - *

    - * - *

    Container properties

    - *
    - *
    Associative
    - *
    - * Elements in associative containers are referenced by their key and not by their absolute - * position in the container. - *
    - * - *
    Set
    - *
    The value of an element is also the key used to identify it.
    - * - *
    Unique keys
    - *
    No two elements in the container can have equivalent keys.
    - *
    - * - * @param Type of the elements. Each element in a {@link SetContainer} container is also identified - * by this value (each value is itself also the element's key). - * - * @author Jeongho Nam - */ - abstract class UniqueSet extends SetContainer { - /** - * @inheritdoc - */ - count(key: T): number; - /** - *

    Extract an element.

    - * - *

    Extracts the element pointed to by val and erases it from the {@link UniqueSet}.

    - * - * @param val Value to be extracted. - * - * @return A value. - */ - extract(val: T): T; - /** - *

    Extract an element.

    - * - *

    Extracts the element pointed to by key and erases it from the {@link UniqueMap}.

    - * - * @param it An iterator pointing an element to extract. - * - * @return An iterator pointing to the element immediately following it prior to the element being - * erased. If no such element exists,returns {@link end end()}. - */ - extract(it: SetIterator): SetIterator; - /** - *

    Extract an element.

    - * - *

    Extracts the element pointed to by key and erases it from the {@link UniqueMap}.

    - * - * @param it An iterator pointing an element to extract. - * - * @return An iterator pointing to the element immediately following it prior to the element being - * erased. If no such element exists,returns {@link end end()}. - */ - extract(it: SetReverseIterator): SetReverseIterator; - /** - * @hidden - */ - private extract_by_key(val); - /** - * @hidden - */ - private extract_by_iterator(it); - /** - * @hidden - */ - private extract_by_reverse_iterator(it); - /** - *

    Insert an element.

    - * - *

    Extends the container by inserting new elements, effectively increasing the container {@link size} by - * the number of element inserted (zero or one).

    - * - *

    Because elements in a {@link UniqueSet UniqueSets} are unique, the insertion operation checks whether - * each inserted element is equivalent to an element already in the container, and if so, the element is not - * inserted, returning an iterator to this existing element (if the function returns a value).

    - * - *

    For a similar container allowing for duplicate elements, see {@link MultiSet}.

    - * - * @param key Value to be inserted as an element. - * - * @return A {@link Pair}, with its member {@link Pair.first} set to an iterator pointing to either the newly - * inserted element or to the equivalent element already in the {@link UniqueSet}. The - * {@link Pair.second} element in the {@link Pair} is set to true if a new element was inserted or - * false if an equivalent element already existed. - */ - insert(val: T): Pair, boolean>; - /** - * @inheritdoc - */ - insert(hint: SetIterator, val: T): SetIterator; - /** - * @inheritdoc - */ - insert(hint: SetReverseIterator, val: T): SetReverseIterator; - /** - * @inheritdoc - */ - insert>(begin: InputIterator, end: InputIterator): void; - /** - * @inheritdoc - */ - swap(obj: UniqueSet): void; - } -} declare namespace std.base { /** *

    An abstract set.

    @@ -6124,8 +6008,8 @@ declare namespace std.base { * {@link List} and registering {@link ListIterator iterators} of the {@link data_ list container} to an index * table like {@link RBTree tree} or {@link HashBuckets hash-table}.

    * - *

    - *

    + *

    + *

    * *

    Container properties

    *
    @@ -6177,163 +6061,6 @@ declare namespace std.base { swap(obj: MultiSet): void; } } -declare namespace std.HashSet { - type iterator = std.SetIterator; - type reverse_iterator = std.SetReverseIterator; -} -declare namespace std { - /** - *

    Hashed, unordered set.

    - * - *

    {@link HashSet}s are containers that store unique elements in no particular order, and which - * allow for fast retrieval of individual elements based on their value.

    - * - *

    In an {@link HashSet}, the value of an element is at the same time its key, that - * identifies it uniquely. Keys are immutable, therefore, the elements in an {@link HashSet} cannot be - * modified once in the container - they can be inserted and removed, though.

    - * - *

    Internally, the elements in the {@link HashSet} are not sorted in any particular order, but - * organized into buckets depending on their hash values to allow for fast access to individual elements - * directly by their values (with a constant average time complexity on average).

    - * - *

    {@link HashSet} containers are faster than {@link TreeSet} containers to access individual - * elements by their key, although they are generally less efficient for range iteration through a - * subset of their elements.

    - * - *

    - *

    - * - *

    Container properties

    - *
    - *
    Associative
    - *
    Elements in associative containers are referenced by their key and not by their absolute - * position in the container.
    - * - *
    Hashed
    - *
    Hashed containers organize their elements using hash tables that allow for fast access to elements - * by their key.
    - * - *
    Set
    - *
    The value of an element is also the key used to identify it.
    - * - *
    Unique keys
    - *
    No two elements in the container can have equivalent keys.
    - *
    - * - * @param Type of the elements. - * Each element in an {@link HashSet} is also uniquely identified by this value. - * - * @reference http://www.cplusplus.com/reference/unordered_set/unordered_set - * @author Jeongho Nam - */ - class HashSet extends base.UniqueSet { - private hash_buckets_; - /** - * @hidden - */ - protected init(): void; - /** - * @hidden - */ - protected construct_from_array(items: Array): void; - /** - * @inheritdoc - */ - clear(): void; - /** - * @inheritdoc - */ - find(key: T): SetIterator; - /** - * @inheritdoc - */ - begin(): SetIterator; - /** - * @inheritdoc - */ - begin(index: number): SetIterator; - /** - * @inheritdoc - */ - end(): SetIterator; - /** - * @inheritdoc - */ - end(index: number): SetIterator; - /** - * @inheritdoc - */ - rbegin(): SetReverseIterator; - /** - * @inheritdoc - */ - rbegin(index: number): SetReverseIterator; - /** - * @inheritdoc - */ - rend(): SetReverseIterator; - /** - * @inheritdoc - */ - rend(index: number): SetReverseIterator; - /** - * @inheritdoc - */ - bucket_count(): number; - /** - * @inheritdoc - */ - bucket_size(n: number): number; - /** - * @inheritdoc - */ - max_load_factor(): number; - /** - * @inheritdoc - */ - max_load_factor(z: number): void; - /** - * @inheritdoc - */ - bucket(key: T): number; - /** - * @inheritdoc - */ - reserve(n: number): void; - /** - * @inheritdoc - */ - rehash(n: number): void; - /** - * @hidden - */ - protected insert_by_val(val: T): any; - /** - * @hidden - */ - protected insert_by_hint(hint: SetIterator, val: T): SetIterator; - /** - * @hidden - */ - protected insert_by_range>(first: InputIterator, last: InputIterator): void; - /** - * @inheritdoc - */ - protected handle_insert(first: SetIterator, last: SetIterator): void; - /** - * @inheritdoc - */ - protected handle_erase(first: SetIterator, last: SetIterator): void; - /** - * @inheritdoc - */ - swap(obj: base.UniqueSet): void; - /** - * @hidden - */ - private swap_tree_set(obj); - } -} declare namespace std.HashMultiSet { type iterator = std.SetIterator; type reverse_iterator = std.SetReverseIterator; @@ -6357,8 +6084,8 @@ declare namespace std { *

    Elements with equivalent values are grouped together in the same bucket and in such a way that an * iterator can iterate through all of them. Iterators in the container are doubly linked iterators.

    * - *

    - *

    + *

    + *

    * *

    Container properties

    *
    @@ -6384,6 +6111,9 @@ declare namespace std { * @author Jeongho Nam */ class HashMultiSet extends base.MultiSet { + /** + * @hidden + */ private hash_buckets_; /** * @hidden @@ -6495,6 +6225,291 @@ declare namespace std { private swap_tree_set(obj); } } +declare namespace std.base { + /** + *

    An abstract set.

    + * + *

    {@link SetContainer SetContainers} are containers that store elements allowing fast retrieval of + * individual elements based on their value.

    + * + *

    In an {@link SetContainer}, the value of an element is at the same time its key, used to uniquely + * identify it. Keys are immutable, therefore, the elements in an {@link SetContainer} cannot be modified + * once in the container - they can be inserted and removed, though.

    + * + *

    {@link SetContainer} stores elements, keeps sequence and enables indexing by inserting elements into a + * {@link List} and registering {@link ListIterator iterators} of the {@link data_ list container} to an index + * table like {@link RBTree tree} or {@link HashBuckets hash-table}.

    + * + *

    + *

    + * + *

    Container properties

    + *
    + *
    Associative
    + *
    + * Elements in associative containers are referenced by their key and not by their absolute + * position in the container. + *
    + * + *
    Set
    + *
    The value of an element is also the key used to identify it.
    + * + *
    Unique keys
    + *
    No two elements in the container can have equivalent keys.
    + *
    + * + * @param Type of the elements. Each element in a {@link SetContainer} container is also identified + * by this value (each value is itself also the element's key). + * + * @author Jeongho Nam + */ + abstract class UniqueSet extends SetContainer { + /** + * @inheritdoc + */ + count(key: T): number; + /** + *

    Extract an element.

    + * + *

    Extracts the element pointed to by val and erases it from the {@link UniqueSet}.

    + * + * @param val Value to be extracted. + * + * @return A value. + */ + extract(val: T): T; + /** + *

    Extract an element.

    + * + *

    Extracts the element pointed to by key and erases it from the {@link UniqueMap}.

    + * + * @param it An iterator pointing an element to extract. + * + * @return An iterator pointing to the element immediately following it prior to the element being + * erased. If no such element exists,returns {@link end end()}. + */ + extract(it: SetIterator): SetIterator; + /** + *

    Extract an element.

    + * + *

    Extracts the element pointed to by key and erases it from the {@link UniqueMap}.

    + * + * @param it An iterator pointing an element to extract. + * + * @return An iterator pointing to the element immediately following it prior to the element being + * erased. If no such element exists,returns {@link end end()}. + */ + extract(it: SetReverseIterator): SetReverseIterator; + /** + * @hidden + */ + private extract_by_key(val); + /** + * @hidden + */ + private extract_by_iterator(it); + /** + * @hidden + */ + private extract_by_reverse_iterator(it); + /** + *

    Insert an element.

    + * + *

    Extends the container by inserting new elements, effectively increasing the container {@link size} by + * the number of element inserted (zero or one).

    + * + *

    Because elements in a {@link UniqueSet UniqueSets} are unique, the insertion operation checks whether + * each inserted element is equivalent to an element already in the container, and if so, the element is not + * inserted, returning an iterator to this existing element (if the function returns a value).

    + * + *

    For a similar container allowing for duplicate elements, see {@link MultiSet}.

    + * + * @param key Value to be inserted as an element. + * + * @return A {@link Pair}, with its member {@link Pair.first} set to an iterator pointing to either the newly + * inserted element or to the equivalent element already in the {@link UniqueSet}. The + * {@link Pair.second} element in the {@link Pair} is set to true if a new element was inserted or + * false if an equivalent element already existed. + */ + insert(val: T): Pair, boolean>; + /** + * @inheritdoc + */ + insert(hint: SetIterator, val: T): SetIterator; + /** + * @inheritdoc + */ + insert(hint: SetReverseIterator, val: T): SetReverseIterator; + /** + * @inheritdoc + */ + insert>(begin: InputIterator, end: InputIterator): void; + /** + * @inheritdoc + */ + swap(obj: UniqueSet): void; + } +} +declare namespace std.HashSet { + type iterator = std.SetIterator; + type reverse_iterator = std.SetReverseIterator; +} +declare namespace std { + /** + *

    Hashed, unordered set.

    + * + *

    {@link HashSet}s are containers that store unique elements in no particular order, and which + * allow for fast retrieval of individual elements based on their value.

    + * + *

    In an {@link HashSet}, the value of an element is at the same time its key, that + * identifies it uniquely. Keys are immutable, therefore, the elements in an {@link HashSet} cannot be + * modified once in the container - they can be inserted and removed, though.

    + * + *

    Internally, the elements in the {@link HashSet} are not sorted in any particular order, but + * organized into buckets depending on their hash values to allow for fast access to individual elements + * directly by their values (with a constant average time complexity on average).

    + * + *

    {@link HashSet} containers are faster than {@link TreeSet} containers to access individual + * elements by their key, although they are generally less efficient for range iteration through a + * subset of their elements.

    + * + *

    + *

    + * + *

    Container properties

    + *
    + *
    Associative
    + *
    Elements in associative containers are referenced by their key and not by their absolute + * position in the container.
    + * + *
    Hashed
    + *
    Hashed containers organize their elements using hash tables that allow for fast access to elements + * by their key.
    + * + *
    Set
    + *
    The value of an element is also the key used to identify it.
    + * + *
    Unique keys
    + *
    No two elements in the container can have equivalent keys.
    + *
    + * + * @param Type of the elements. + * Each element in an {@link HashSet} is also uniquely identified by this value. + * + * @reference http://www.cplusplus.com/reference/unordered_set/unordered_set + * @author Jeongho Nam + */ + class HashSet extends base.UniqueSet { + /** + * @hidden + */ + private hash_buckets_; + /** + * @hidden + */ + protected init(): void; + /** + * @hidden + */ + protected construct_from_array(items: Array): void; + /** + * @inheritdoc + */ + clear(): void; + /** + * @inheritdoc + */ + find(key: T): SetIterator; + /** + * @inheritdoc + */ + begin(): SetIterator; + /** + * @inheritdoc + */ + begin(index: number): SetIterator; + /** + * @inheritdoc + */ + end(): SetIterator; + /** + * @inheritdoc + */ + end(index: number): SetIterator; + /** + * @inheritdoc + */ + rbegin(): SetReverseIterator; + /** + * @inheritdoc + */ + rbegin(index: number): SetReverseIterator; + /** + * @inheritdoc + */ + rend(): SetReverseIterator; + /** + * @inheritdoc + */ + rend(index: number): SetReverseIterator; + /** + * @inheritdoc + */ + bucket_count(): number; + /** + * @inheritdoc + */ + bucket_size(n: number): number; + /** + * @inheritdoc + */ + max_load_factor(): number; + /** + * @inheritdoc + */ + max_load_factor(z: number): void; + /** + * @inheritdoc + */ + bucket(key: T): number; + /** + * @inheritdoc + */ + reserve(n: number): void; + /** + * @inheritdoc + */ + rehash(n: number): void; + /** + * @hidden + */ + protected insert_by_val(val: T): any; + /** + * @hidden + */ + protected insert_by_hint(hint: SetIterator, val: T): SetIterator; + /** + * @hidden + */ + protected insert_by_range>(first: InputIterator, last: InputIterator): void; + /** + * @inheritdoc + */ + protected handle_insert(first: SetIterator, last: SetIterator): void; + /** + * @inheritdoc + */ + protected handle_erase(first: SetIterator, last: SetIterator): void; + /** + * @inheritdoc + */ + swap(obj: base.UniqueSet): void; + /** + * @hidden + */ + private swap_tree_set(obj); + } +} declare namespace std.List { type iterator = std.ListIterator; type reverse_iterator = std.ListReverseIterator; @@ -6523,8 +6538,8 @@ declare namespace std { * distance between these. They also consume some extra memory to keep the linking information associated to each * element (which may be an important factor for large lists of small-sized elements).

    * - *

    - * + *

    + * *

    * *

    Container properties

    @@ -6546,15 +6561,15 @@ declare namespace std { */ class List extends base.Container implements base.IDequeContainer { /** - * An iterator of beginning. + * @hidden */ protected begin_: ListIterator; /** - * An iterator of end. + * @hidden */ protected end_: ListIterator; /** - * Number of elements in the {@link List}. + * @hidden */ protected size_: number; /** @@ -7096,8 +7111,8 @@ declare namespace std { /** *

    An iterator, node of a List.

    * - *

    - * + *

    + * *

    * * @author Jeongho Nam @@ -7143,6 +7158,11 @@ declare namespace std { /** * @inheritdoc */ + /** + * Set value of the iterator is pointing to. + * + * @param val Value to set. + */ value: T; /** * @inheritdoc @@ -7158,8 +7178,8 @@ declare namespace std { /** *

    A reverse-iterator of List.

    * - *

    - * + *

    + * *

    * * @param Type of the elements. @@ -7167,13 +7187,20 @@ declare namespace std { * @author Jeongho Nam */ class ListReverseIterator extends ReverseIterator, ListReverseIterator> { + /** + * Construct from base iterator. + * + * @param base A reference of the base iterator, which iterates in the opposite direction. + */ constructor(base: ListIterator); /** - * @inheritdoc + * @hidden */ protected create_neighbor(): ListReverseIterator; /** - * @inheritdoc + * Set value of the iterator is pointing to. + * + * @param val Value to set. */ value: T; } @@ -7208,8 +7235,8 @@ declare namespace std { * By default, if no container class is specified for a particular {@link Queue} class instantiation, the standard * container {@link List} is used.

    * - *

    - * + *

    + * *

    * * @param Type of elements. @@ -7540,8 +7567,8 @@ declare namespace std { * By default, if no container class is specified for a particular {@link Stack} class instantiation, the standard * container {@link List} is used.

    * - *

    - * + *

    + * *

    * * @param Type of elements. @@ -7651,18 +7678,18 @@ declare namespace std.base { * so that they can be interpreted when needed as more abstract (and portable) * {@link ErrorCondition error conditions}.

    * - *

    - *

    + *

    + *

    * * @author Jeongho Nam */ abstract class ErrorInstance { /** - * A reference to an {@link ErrorCategory} object. + * @hidden */ protected category_: ErrorCategory; /** - * A numerical value identifying an error instance. + * @hidden */ protected value_: number; /** @@ -7761,15 +7788,15 @@ declare namespace std { *

    The class inherits from {@link RuntimeError}, to which it adds an {@link ErrorCode} as * member code (and defines a specialized what member).

    * - *

    - *

    + *

    + *

    * * @reference http://www.cplusplus.com/reference/system_error/system_error * @author Jeongho Nam */ class SystemError extends RuntimeError { /** - * Error code. + * @hidden */ protected code_: ErrorCode; /** @@ -7827,8 +7854,8 @@ declare namespace std { * passed by reference. As such, only one object of each of these types shall exist, each uniquely identifying its own * category: all error codes and conditions of a same category shall return a reference to same object.

    * - *

    - *

    + *

    + *

    * * @reference http://www.cplusplus.com/reference/system_error/error_category * @author Jeongho Nam @@ -7955,8 +7982,8 @@ declare namespace std { *

    The {@link ErrorCategory categories} associated with the {@link ErrorCondition} and the * {@link ErrorCode} define the equivalences between them.

    * - *

    - *

    + *

    + *

    * * @reference http://www.cplusplus.com/reference/system_error/error_condition * @author Jeongho Nam @@ -7988,8 +8015,8 @@ declare namespace std { *

    Objects of this class associate such numerical codes to {@link ErrorCategory error categories}, so that they * can be interpreted when needed as more abstract (and portable) {@link ErrorCondition error conditions}.

    * - *

    - *

    + *

    + *

    * * @reference http://www.cplusplus.com/reference/system_error/error_code * @author Jeongho Nam @@ -8034,8 +8061,8 @@ declare namespace std { * *

    {@link TreeMap}s are typically implemented as binary search trees.

    * - *

    - *

    + *

    + *

    * *

    Container properties

    *
    @@ -8063,7 +8090,7 @@ declare namespace std { */ class TreeMap extends base.UniqueMap implements base.ITreeMap { /** - * RB-Tree+ object for implemeting the {@link TreeMap}. + * @hidden */ private tree_; /** @@ -8216,8 +8243,8 @@ declare namespace std { * *

    {@link TreeMultiMap TreeMultiMaps} are typically implemented as binary search trees.

    * - *

    < - * img src="http://samchon.github.io/typescript-stl/api/assets/images/design/map_containers.png" style="max-width: 100%" />

    + *

    < + * img src="http://samchon.github.io/typescript-stl/images/design/class_diagram/map_containers.png" style="max-width: 100%" />

    * *

    Container properties

    *
    @@ -8250,6 +8277,9 @@ declare namespace std { * @author Jeongho Nam */ class TreeMultiMap extends base.MultiMap implements base.ITreeMap { + /** + * @hidden + */ private tree_; /** * Default Constructor. @@ -8377,169 +8407,6 @@ declare namespace std { private swap_tree_multimap(obj); } } -declare namespace std.TreeSet { - type iterator = std.SetIterator; - type reverse_iterator = std.SetReverseIterator; -} -declare namespace std { - /** - *

    Tree-structured set, std::set of STL.

    - * - *

    {@link TreeSet}s are containers that store unique elements following a specific order.

    - * - *

    In a {@link TreeSet}, the value of an element also identifies it (the value is itself the - * key, of type T), and each value must be unique. The value of the elements in a - * {@link TreeSet} cannot be modified once in the container (the elements are always const), but they - * can be inserted or removed from the

    - * - *

    Internally, the elements in a {@link TreeSet} are always sorted following a specific strict weak - * ordering criterion indicated by its internal comparison method (of {@link less}).

    - * - *

    {@link TreeSet} containers are generally slower than {@link HashSet} containers to access - * individual elements by their key, but they allow the direct iteration on subsets based on their - * order.

    - * - *

    {@link TreeSet}s are typically implemented as binary search trees.

    - * - *

    - *

    - * - *

    Container properties

    - *
    - *
    Associative
    - *
    - * Elements in associative containers are referenced by their key and not by their absolute - * position in the container. - *
    - * - *
    Ordered
    - *
    - * The elements in the container follow a strict order at all times. All inserted elements are - * given a position in this order. - *
    - * - *
    Set
    - *
    The value of an element is also the key used to identify it.
    - * - *
    Unique keys
    - *
    No two elements in the container can have equivalent keys.
    - *
    - * - * @param Type of the elements. - * Each element in an {@link TreeSet} is also uniquely identified by this value. - * - * @reference http://www.cplusplus.com/reference/set/set - * @author Jeongho Nam - */ - class TreeSet extends base.UniqueSet implements base.ITreeSet { - /** - * RB-Tree+ object for implemeting the {@link TreeSet}. - */ - private tree_; - /** - * Default Constructor. - */ - constructor(); - /** - * Construct from compare. - * - * @param compare A binary predicate determines order of elements. - */ - constructor(compare: (x: T, y: T) => boolean); - /** - * Contruct from elements. - * - * @param array Elements to be contained. - */ - constructor(array: Array); - /** - * Contruct from elements with compare. - * - * @param array Elements to be contained. - * @param compare A binary predicate determines order of elements. - */ - constructor(array: Array, compare: (x: T, y: T) => boolean); - /** - * Copy Constructor. - */ - constructor(container: base.IContainer); - /** - * Copy Constructor with compare. - * - * @param container A container to be copied. - * @param compare A binary predicate determines order of elements. - */ - constructor(container: base.IContainer, compare: (x: T, y: T) => boolean); - /** - * Range Constructor. - * - * @param begin Input interator of the initial position in a sequence. - * @param end Input interator of the final position in a sequence. - */ - constructor(begin: Iterator, end: Iterator); - /** - * Range Constructor with compare. - * - * @param begin Input interator of the initial position in a sequence. - * @param end Input interator of the final position in a sequence. - * @param compare A binary predicate determines order of elements. - */ - constructor(begin: Iterator, end: Iterator, compare: (x: T, y: T) => boolean); - /** - * @inheritdoc - */ - clear(): void; - /** - * @inheritdoc - */ - find(val: T): SetIterator; - /** - * @inheritdoc - */ - key_comp(): (x: T, y: T) => boolean; - /** - * @inheritdoc - */ - value_comp(): (x: T, y: T) => boolean; - /** - * @inheritdoc - */ - lower_bound(val: T): SetIterator; - /** - * @inheritdoc - */ - upper_bound(val: T): SetIterator; - /** - * @inheritdoc - */ - equal_range(val: T): Pair, SetIterator>; - /** - * @hidden - */ - protected insert_by_val(val: T): any; - protected insert_by_hint(hint: SetIterator, val: T): SetIterator; - /** - * @hidden - */ - protected insert_by_range>(first: InputIterator, last: InputIterator): void; - /** - * @inheritdoc - */ - protected handle_insert(first: SetIterator, last: SetIterator): void; - /** - * @inheritdoc - */ - protected handle_erase(first: SetIterator, last: SetIterator): void; - /** - * @inheritdoc - */ - swap(obj: base.UniqueSet): void; - /** - * @hidden - */ - private swap_tree_set(obj); - } -} declare namespace std.TreeMultiSet { type iterator = std.SetIterator; type reverse_iterator = std.SetReverseIterator; @@ -8565,8 +8432,8 @@ declare namespace std { * *

    {@link TreeMultiSet TreeMultiSets} are typically implemented as binary search trees.

    * - *

    - *

    + *

    + *

    * *

    Container properties

    *
    @@ -8597,7 +8464,7 @@ declare namespace std { */ class TreeMultiSet extends base.MultiSet implements base.ITreeSet { /** - * RB-Tree+ object for implemeting the {@link TreeMultiSet}. + * @hidden */ private tree_; /** @@ -8711,6 +8578,169 @@ declare namespace std { private swap_tree_set(obj); } } +declare namespace std.TreeSet { + type iterator = std.SetIterator; + type reverse_iterator = std.SetReverseIterator; +} +declare namespace std { + /** + *

    Tree-structured set, std::set of STL.

    + * + *

    {@link TreeSet}s are containers that store unique elements following a specific order.

    + * + *

    In a {@link TreeSet}, the value of an element also identifies it (the value is itself the + * key, of type T), and each value must be unique. The value of the elements in a + * {@link TreeSet} cannot be modified once in the container (the elements are always const), but they + * can be inserted or removed from the

    + * + *

    Internally, the elements in a {@link TreeSet} are always sorted following a specific strict weak + * ordering criterion indicated by its internal comparison method (of {@link less}).

    + * + *

    {@link TreeSet} containers are generally slower than {@link HashSet} containers to access + * individual elements by their key, but they allow the direct iteration on subsets based on their + * order.

    + * + *

    {@link TreeSet}s are typically implemented as binary search trees.

    + * + *

    + *

    + * + *

    Container properties

    + *
    + *
    Associative
    + *
    + * Elements in associative containers are referenced by their key and not by their absolute + * position in the container. + *
    + * + *
    Ordered
    + *
    + * The elements in the container follow a strict order at all times. All inserted elements are + * given a position in this order. + *
    + * + *
    Set
    + *
    The value of an element is also the key used to identify it.
    + * + *
    Unique keys
    + *
    No two elements in the container can have equivalent keys.
    + *
    + * + * @param Type of the elements. + * Each element in an {@link TreeSet} is also uniquely identified by this value. + * + * @reference http://www.cplusplus.com/reference/set/set + * @author Jeongho Nam + */ + class TreeSet extends base.UniqueSet implements base.ITreeSet { + /** + * @hidden + */ + private tree_; + /** + * Default Constructor. + */ + constructor(); + /** + * Construct from compare. + * + * @param compare A binary predicate determines order of elements. + */ + constructor(compare: (x: T, y: T) => boolean); + /** + * Contruct from elements. + * + * @param array Elements to be contained. + */ + constructor(array: Array); + /** + * Contruct from elements with compare. + * + * @param array Elements to be contained. + * @param compare A binary predicate determines order of elements. + */ + constructor(array: Array, compare: (x: T, y: T) => boolean); + /** + * Copy Constructor. + */ + constructor(container: base.IContainer); + /** + * Copy Constructor with compare. + * + * @param container A container to be copied. + * @param compare A binary predicate determines order of elements. + */ + constructor(container: base.IContainer, compare: (x: T, y: T) => boolean); + /** + * Range Constructor. + * + * @param begin Input interator of the initial position in a sequence. + * @param end Input interator of the final position in a sequence. + */ + constructor(begin: Iterator, end: Iterator); + /** + * Range Constructor with compare. + * + * @param begin Input interator of the initial position in a sequence. + * @param end Input interator of the final position in a sequence. + * @param compare A binary predicate determines order of elements. + */ + constructor(begin: Iterator, end: Iterator, compare: (x: T, y: T) => boolean); + /** + * @inheritdoc + */ + clear(): void; + /** + * @inheritdoc + */ + find(val: T): SetIterator; + /** + * @inheritdoc + */ + key_comp(): (x: T, y: T) => boolean; + /** + * @inheritdoc + */ + value_comp(): (x: T, y: T) => boolean; + /** + * @inheritdoc + */ + lower_bound(val: T): SetIterator; + /** + * @inheritdoc + */ + upper_bound(val: T): SetIterator; + /** + * @inheritdoc + */ + equal_range(val: T): Pair, SetIterator>; + /** + * @hidden + */ + protected insert_by_val(val: T): any; + protected insert_by_hint(hint: SetIterator, val: T): SetIterator; + /** + * @hidden + */ + protected insert_by_range>(first: InputIterator, last: InputIterator): void; + /** + * @inheritdoc + */ + protected handle_insert(first: SetIterator, last: SetIterator): void; + /** + * @inheritdoc + */ + protected handle_erase(first: SetIterator, last: SetIterator): void; + /** + * @inheritdoc + */ + swap(obj: base.UniqueSet): void; + /** + * @hidden + */ + private swap_tree_set(obj); + } +} declare namespace std { /** *

    Running on Node.

    @@ -8818,8 +8848,8 @@ declare namespace std { * end, they perform worse than the others, and have less consistent iterators and references than {@link List}s. *

    * - *

    - * + *

    + * *

    * *

    Container properties

    @@ -9200,8 +9230,8 @@ declare namespace std { /** *

    An iterator of Vector.

    * - *

    - * + *

    + * *

    * * @param Type of the elements. @@ -9232,7 +9262,9 @@ declare namespace std { * @inheritdoc */ /** - * Set value. + * Set value of the iterator is pointing to. + * + * @param val Value to set. */ value: T; /** @@ -9277,8 +9309,8 @@ declare namespace std { /** *

    A reverse-iterator of Vector.

    * - *

    - * + *

    + * *

    * * @param Type of the elements. @@ -9286,13 +9318,20 @@ declare namespace std { * @author Jeongho Nam */ class VectorReverseIterator extends ReverseIterator, VectorReverseIterator> implements base.IArrayIterator { + /** + * Construct from base iterator. + * + * @param base A reference of the base iterator, which iterates in the opposite direction. + */ constructor(base: VectorIterator); /** - * @inheritdoc + * @hidden */ protected create_neighbor(): VectorReverseIterator; /** - * Set value. + * Set value of the iterator is pointing to. + * + * @param val Value to set. */ value: T; /** @@ -9353,7 +9392,13 @@ declare namespace std.base { * @author Jeongho Nam */ class HashBuckets { + /** + * @hidden + */ private buckets_; + /** + * @hidden + */ private item_size_; /** * Default Constructor. @@ -9400,8 +9445,8 @@ declare namespace std.base { *

    Elements with equivalent keys are grouped together in the same bucket and in such a way that * an iterator can iterate through all of them. Iterators in the container are doubly linked iterators.

    * - *

    - * + *

    + * *

    * *

    Container properties

    @@ -9696,8 +9741,8 @@ declare namespace std.base { /** *

    Hash buckets storing {@link MapIterator MapIterators}.

    * - *

    - * + *

    + * *

    * * @author Jeongho Nam @@ -9727,8 +9772,8 @@ declare namespace std.base { * elements by their key, although they are generally less efficient for range iteration through a * subset of their elements.

    * - *

    - * + *

    + * *

    * *

    Container properties

    @@ -9951,8 +9996,8 @@ declare namespace std.base { /** *

    Hash buckets storing {@link SetIterator SetIterators}.

    * - *

    - * + *

    + * *

    * * @author Jeongho Nam @@ -9993,8 +10038,8 @@ declare namespace std.base { * beginning or the end, {@link IArray} objects perform worse and have less consistent iterators and references * than {@link List Lists}

    . * - *

    - * + *

    + * *

    * *

    Container properties

    @@ -10107,8 +10152,8 @@ declare namespace std.base { *

    There is not a single type of {@link IArrayIterator random-access iterator}: Each container may define its * own specific iterator type able to iterate through it and access its elements.

    * - *

    - * + *

    + * *

    * * @reference http://www.cplusplus.com/reference/iterator/RandomAccessIterator @@ -10138,8 +10183,8 @@ declare namespace std.base { *

    {@link IContainer} is an interface designed for sequence containers. Sequence containers of STL * (Standard Template Library) are based on the {@link IContainer}.

    * - *

    - * + *

    + * *

    * *

    Container properties

    @@ -10330,8 +10375,8 @@ declare namespace std.base { /** *

    An interface for deque

    * - *

    - * + *

    + * *

    * * @author Jeongho Nam @@ -10360,8 +10405,8 @@ declare namespace std.base { /** *

    An interface for linear containers.

    * - *

    - * + *

    + * *

    * * @author Jeonngho Nam @@ -10522,7 +10567,7 @@ declare namespace std.base { * * * - *

    * *

    These constraints enforce a critical property of red-black trees: the path from the root to the farthest @@ -10717,7 +10762,7 @@ declare namespace std.base { * the only loop, and any rotations occur after this loop, this proves that a constant number of rotations * occur.

    * - *

    * * @param N A node to be inserted or swapped. @@ -10751,7 +10796,7 @@ declare namespace std.base { * node are black) is still violated, but now we can resolve this by * continuing to case 5.

    * - *

    * * @param N A node to be inserted or swapped. @@ -10782,7 +10827,7 @@ declare namespace std.base { * through {@link XTreeNode.parent P}. In each case, this is the only * black node of the three.

    * - *

    * * @param N A node to be inserted or swapped. @@ -10936,7 +10981,7 @@ declare namespace std.base { /** *

    {@link XTreeNode.sibling S} is red.

    * - *

    * *

    In this case we reverse the colors of {@link XTreeNode.parent P} and @@ -10958,7 +11003,7 @@ declare namespace std.base { *

    {@link XTreeNode.parent P}, {@link XTreeNode.sibling S}, and {@link XTreeNode.sibling * S}'s children are black.

    * - *

    * *

    In this case, we simply repaint {@link XTreeNode.sibling S} red. The @@ -10982,7 +11027,7 @@ declare namespace std.base { *

    {@link XTreeNode.sibling S} and {@link XTreeNode.sibling S}'s children are * black, but {@link XTreeNode.parent P} is red.

    * - *

    * *

    In this case, we simply exchange the colors of {@link XTreeNode.sibling S} and @@ -10999,7 +11044,7 @@ declare namespace std.base { * left child is red, {@link XTreeNode.sibling S}'s right child is * black, and N is the left child of its parent.

    * - *

    * *

    In this case we rotate right at {@link XTreeNode.sibling S}, so that @@ -11038,7 +11083,7 @@ declare namespace std.base { *

    Thus, the paths passing through N pass through one additional * black node.

    * - *

    * *

    Meanwhile, if a path does not go through N, then there are two possibilities:

    @@ -11122,8 +11167,8 @@ declare namespace std.base { * *

    {@link ITreeMap TreeMultiMaps} are typically implemented as binary search trees.

    * - *

    - *

    + *

    + *

    * *

    Container properties

    *
    @@ -11257,13 +11302,19 @@ declare namespace std.base { /** *

    A red-black tree storing {@link MapIterator MapIterators}.

    * - *

    - *

    + *

    + *

    * * @author Jeongho Nam */ class PairTree extends XTree> { + /** + * @hidden + */ private map_; + /** + * @hidden + */ private compare_; /** * Default Constructor. @@ -11409,8 +11460,8 @@ declare namespace std.base { * *

    {@link ITreeSet TreeMultiSets} are typically implemented as binary search trees.

    * - *

    - *

    + *

    + *

    * *

    Container properties

    *
    @@ -11551,13 +11602,19 @@ declare namespace std.base { /** *

    A red-black Tree storing {@link SetIterator SetIterators}.

    * - *

    - *

    + *

    + *

    * * @author Jeongho Nam */ class AtomicTree extends XTree> { + /** + * @hidden + */ private set_; + /** + * @hidden + */ private compare_; /** * Default Constructor. @@ -11738,27 +11795,3 @@ declare namespace std.base { uncle: XTreeNode; } } -declare namespace std.example { - function test_all(): void; -} -declare namespace std.example { - function test_bind(): void; -} -declare namespace std.example { - function test_deque(): void; -} -declare namespace std.example { - function test_for_each(): void; -} -declare namespace std.example { - function test_hash_map(): void; -} -declare namespace std.example { - function test_list(): void; -} -declare namespace std.example { - function sorting(): void; -} -declare namespace std.example { - function tree_set(): void; -}