Formal Big O/Theta notation in docblocks for Evented trait

This annotation is my own---there is not currently a system, insofar as I
know, that uses it. I'll be further formalizing things like this as I go,
but the idea is that I wish to provide asymptotic computational complexity
for all algorithms. Usually, these will be in Big O notation, which is
used (for better or for worse) to denote the upper bound of asymptomatic
growth. I will provide as tight of estimates as I can. Where the estimates
between upper and lower bounds differ significantly, I will provide both;
where they converge strongly, I'll use Big Theta notation---denoted by a
`@Theta` annotation---except in the case of constant time, for which I will
simply stick with Big O.
events
Mike Gerwitz 2014-07-30 23:00:48 -04:00
parent 981d8b923a
commit a543d3f950
1 changed files with 12 additions and 0 deletions

View File

@ -60,6 +60,8 @@ module.exports = Trait( 'Evented',
* accidentally mixing callbacks when an event is assumed to have not
* already been defined.
*
* @Theta {n} relative to number of events
*
* @param {Array.<string>} ids list of event ids
* @return {Evented} self
*
@ -82,6 +84,8 @@ module.exports = Trait( 'Evented',
*
* If an id is already defined, an exception will be thrown.
*
* @Theta {n} relative to number of events
*
* @param {Array.<string>} ids event ids
* @return {undefined}
*
@ -110,6 +114,8 @@ module.exports = Trait( 'Evented',
* See documentation for the `scheduleCallbacks` method for information
* on the default callback scheduler.
*
* @O {#scheduleCallbacks} dependent on scheduler
*
* @param {string} ev defined event id
* @return {Evented} self
*/
@ -140,6 +146,8 @@ module.exports = Trait( 'Evented',
* this method can be overridden to provide a different scheduler that
* provides different guarantees.
*
* @O {n} where n = <# registerd listeners> + <# gaps> for event EV
*
* @param {string} ev defined event id
* @param {Array.<Function>} evc event callbacks (listeners)
* @param {Array} args argument list to apply to callbacks
@ -198,6 +206,8 @@ module.exports = Trait( 'Evented',
* (by not forwarding the listener to __supet) and instead invoke
* __super with a new listener, possibly wrapping the original.
*
* @O {1} constant time
*
* @param {string} ev defined event id
* @param {Function} listener function to invoke when event is emitted
*
@ -232,6 +242,8 @@ module.exports = Trait( 'Evented',
* Listeners are compared by reference---the exact listener that was
* registered with EV must be passed for removal.
*
* @O {1} constant time
*
* @param {string} ev defined event id
* @param {Function} listener listener to remove
*