UNPKG

gojs

Version:

Interactive diagrams, charts, and graphs, such as trees, flowcharts, orgcharts, UML, BPMN, or business diagrams

469 lines (468 loc) 25 kB
<!doctype html> <html class="default no-js"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>Iterator | GoJS API</title> <meta name="description" content="Documentation for GoJS API"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="../../assets/css/style.css"> <link rel="stylesheet" href="../assets/css/main.css"> <script async src="../assets/js/search.js" id="search-script"></script> </head> <body> <header> <nav id="navTop" class="w-full z-30 top-0 text-white bg-nwoods-primary"> <div class="w-full container max-w-screen-lg mx-auto flex flex-wrap sm:flex-nowrap items-center justify-between mt-0 py-2"> <div class="md:pl-4"> <a class="text-white hover:text-white no-underline hover:no-underline font-bold text-2xl lg:text-4xl rounded-lg hover:bg-nwoods-secondary" href="../../index.html"> <h1 class="mb-0 p-1 leading-none">GoJS</h1> </a> </div> <button id="topnavButton" class="rounded-lg sm:hidden focus:outline-none focus:ring" aria-label="Navigation"> <svg fill="currentColor" viewBox="0 0 20 20" class="w-6 h-6"> <path id="topnavOpen" fill-rule="evenodd" d="M3 5a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1zM3 10a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1zM9 15a1 1 0 011-1h6a1 1 0 110 2h-6a1 1 0 01-1-1z" clip-rule="evenodd"></path> <path id="topnavClosed" class="hidden" fill-rule="evenodd" d="M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z" clip-rule="evenodd"></path> </svg> </button> <div id="topnavList" class="hidden sm:block items-center w-auto mt-0 text-white p-0 z-20"> <ul class="list-reset list-none font-semibold flex justify-end flex-wrap sm:flex-nowrap items-center px-0 pb-0"> <li class="p-1 sm:p-0"><a class="topnav-link" href="../../learn/index.html">Learn</a></li> <li class="p-1 sm:p-0"><a class="topnav-link" href="../../samples/index.html">Samples</a></li> <li class="p-1 sm:p-0"><a class="topnav-link" href="../../intro/index.html">Intro</a></li> <li class="p-1 sm:p-0"><a class="topnav-link" href="../../api/index.html">API</a></li> <li class="p-1 sm:p-0"><a class="topnav-link" href="https://www.nwoods.com/products/register.html">Register</a></li> <li class="p-1 sm:p-0"><a class="topnav-link" href="../../download.html">Download</a></li> <li class="p-1 sm:p-0"><a class="topnav-link" href="https://forum.nwoods.com/c/gojs/11">Forum</a></li> <li class="p-1 sm:p-0"><a class="topnav-link" href="https://www.nwoods.com/contact.html" target="_blank" rel="noopener" onclick="getOutboundLink('https://www.nwoods.com/contact.html', 'contact');">Contact</a></li> <li class="p-1 sm:p-0"><a class="topnav-link" href="https://www.nwoods.com/sales/index.html" target="_blank"rel="noopener" onclick="getOutboundLink('https://www.nwoods.com/sales/index.html', 'buy');">Buy</a></li> </ul> </div> </div> <hr class="border-b border-gray-600 opacity-50 my-0 py-0" /> </nav> <div class="tsd tsd-page-header"> <div class="tsd-page-toolbar"> <div class="w-full max-w-screen-xl mx-auto px-2"> <div class="table-wrap"> <div class="table-cell" id="tsd-search" data-index="../assets/js/search.json" data-base=".."> <div class="field"> <label for="tsd-search-field" class="tsd-widget search no-caption">Search</label> <input id="tsd-search-field" type="text" /> </div> <ul class="results"> <li class="state loading">Preparing search index...</li> <li class="state failure">The search index is not available</li> </ul> <a href="../index.html" class="title">GoJS API</a> </div> <div class="table-cell" id="tsd-widgets"> <div id="tsd-filter"> <a href="#" class="tsd-widget options no-caption" data-toggle="options">Options</a> <div class="tsd-filter-group"> <div class="tsd-select" id="tsd-filter-visibility"> <span class="tsd-select-label">All</span> <ul class="tsd-select-list"> <li data-value="public">Public</li> <li data-value="protected">Public/Protected</li> <li data-value="private" class="selected">All</li> </ul> </div> </div> </div> <a href="#" class="tsd-widget menu no-caption" data-toggle="menu">Menu</a> </div> </div> </div> </div> <div class="tsd tsd-page-title"> <div class="w-full max-w-screen-xl mx-auto px-2"> <div class="top-copyright"> <b>GoJS</b>&reg; Diagramming Components<br/>version 2.1.56<br/>by <a href="https://www.nwoods.com/">Northwoods Software&reg;</a> </div> <div> <h1>Interface Iterator&lt;T&gt;</h1> </div> </div> </div> </div> </header> <div class="tsd w-full max-w-screen-xl mx-auto pb-4"> <div class="row px-2 w-full"> <div class="col-8 col-content"> <section class="tsd-panel tsd-hierarchy"> <h3>Hierarchy</h3> <ul class="tsd-hierarchy"> <li> <a href="Iterable.html" class="tsd-signature-type" data-tsd-kind="Interface">Iterable</a><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">T</span><span class="tsd-signature-symbol">&gt;</span> <ul class="tsd-hierarchy"> <li> <span class="target">Iterator</span> </li> </ul> </li> </ul> </section> <section class="tsd-panel tsd-comment"> <div class="tsd-comment tsd-typography"> <p>This interface defines properties and methods for iterating over a collection; it provides the <a href="Iterator.html#next">next</a> predicate and the <a href="Iterator.html#value">value</a> read-only property. Some Iterators also provide <code>key</code> property values along with each <code>value</code>.</p> <p>Typical usage is:</p> <pre><code class="language-js"><span style="color: #D4D4D4"> </span><span style="color: #569CD6">var</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">it</span><span style="color: #D4D4D4"> = </span><span style="color: #9CDCFE">anIterableCollection</span><span style="color: #D4D4D4">.</span><span style="color: #9CDCFE">iterator</span><span style="color: #D4D4D4">;</span> <span style="color: #D4D4D4"> </span><span style="color: #C586C0">while</span><span style="color: #D4D4D4"> (</span><span style="color: #9CDCFE">it</span><span style="color: #D4D4D4">.</span><span style="color: #DCDCAA">next</span><span style="color: #D4D4D4">()) {</span> <span style="color: #D4D4D4"> </span><span style="color: #569CD6">var</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">item</span><span style="color: #D4D4D4"> = </span><span style="color: #9CDCFE">it</span><span style="color: #D4D4D4">.</span><span style="color: #9CDCFE">value</span><span style="color: #D4D4D4">;</span> <span style="color: #D4D4D4"> }</span> </code></pre> <p>Many iterators will signal an error if <a href="Iterator.html#next">next</a> is called after the underlying collection has been modified.</p> <p>To avoid confusion when dealing with <a href="Iterable.html">Iterable</a>s, iterators implement the <a href="Iterable.html#iterator">Iterable.iterator</a> property by just returning themselves.</p> </div> </section> <section class="tsd-panel tsd-type-parameters"> <h3>Type parameters</h3> <ul class="tsd-type-parameters"> <li> <h4>T</h4> </li> </ul> </section> <section class="tsd-panel-group tsd-index-group"> <h2>Index</h2> <section class="tsd-panel tsd-index-panel"> <div class="tsd-index-content"> <section class="tsd-index-section "> <h3>Properties</h3> <ul class="tsd-index-list"> <li class="tsd-kind-property tsd-parent-kind-interface tsd-is-overwrite"><a href="Iterator.html#count" class="tsd-kind-icon">count</a></li> <li class="tsd-kind-property tsd-parent-kind-interface tsd-is-overwrite"><a href="Iterator.html#iterator" class="tsd-kind-icon">iterator</a></li> <li class="tsd-kind-property tsd-parent-kind-interface"><a href="Iterator.html#key" class="tsd-kind-icon">key</a></li> <li class="tsd-kind-property tsd-parent-kind-interface"><a href="Iterator.html#value" class="tsd-kind-icon">value</a></li> </ul> </section> <section class="tsd-index-section "> <h3>Methods</h3> <ul class="tsd-index-list"> <li class="tsd-kind-method tsd-parent-kind-interface"><a href="Iterator.html#all" class="tsd-kind-icon">all</a></li> <li class="tsd-kind-method tsd-parent-kind-interface"><a href="Iterator.html#any" class="tsd-kind-icon">any</a></li> <li class="tsd-kind-method tsd-parent-kind-interface"><a href="Iterator.html#each" class="tsd-kind-icon">each</a></li> <li class="tsd-kind-method tsd-parent-kind-interface tsd-is-overwrite"><a href="Iterator.html#first" class="tsd-kind-icon">first</a></li> <li class="tsd-kind-method tsd-parent-kind-interface"><a href="Iterator.html#next" class="tsd-kind-icon">next</a></li> <li class="tsd-kind-method tsd-parent-kind-interface"><a href="Iterator.html#reset" class="tsd-kind-icon">reset</a></li> </ul> </section> </div> </section> </section> <section class="tsd-panel-group tsd-member-group "> <h2>Properties</h2> <section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface tsd-is-overwrite"> <a name="count" class="tsd-anchor"></a> <h3> <span class="tsd-flag ts-flagReadonly">Readonly</span> <span class="tsd-flag ts-flagOverride">Override</span> count <span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span> </h3> <div class="tsd-comment tsd-typography"> <p>This read-only property is the total number of items in the iterated collection.</p> </div> </section> <section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface tsd-is-overwrite"> <a name="iterator" class="tsd-anchor"></a> <h3> <span class="tsd-flag ts-flagOverride">Override</span> iterator <span class="tsd-signature-symbol">: </span><a href="Iterator.html" class="tsd-signature-type" data-tsd-kind="Interface">Iterator</a><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">T</span><span class="tsd-signature-symbol">&gt;</span> </h3> <div class="tsd-comment tsd-typography"> <p>Returns itself, which is convenient for code that expects an <a href="Iterable.html">Iterable</a> instead of an <a href="Iterator.html">Iterator</a>.</p> </div> </section> <section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface"> <a name="key" class="tsd-anchor"></a> <h3> <span class="tsd-flag ts-flagReadonly">Readonly</span> key <span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">any</span> </h3> <div class="tsd-comment tsd-typography"> <p>Gets the current index to the item in the collection, assuming <a href="Iterator.html#next">next</a> has just returned true.</p> </div> </section> <section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface"> <a name="value" class="tsd-anchor"></a> <h3> <span class="tsd-flag ts-flagReadonly">Readonly</span> value <span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">T</span> </h3> <div class="tsd-comment tsd-typography"> <p>Gets the current item in the collection, assuming <a href="Iterator.html#next">next</a> has just returned true.</p> </div> </section> </section> <section class="tsd-panel-group tsd-member-group "> <h2>Methods</h2> <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-interface"> <a name="all" class="tsd-anchor"></a> <h3> <span class="tsd-flag ts-flagVirtual">Virtual</span> all </h3> <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-interface"> <li class="tsd-signature tsd-kind-icon">all<span class="tsd-signature-symbol">(</span>pred<span class="tsd-signature-symbol">: </span><span class="tsd-signature-symbol">(</span>x<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">T</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol"> =&gt; </span><span class="tsd-signature-type">boolean</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">boolean</span></li> </ul> <ul class="tsd-descriptions"> <li class="tsd-description"> <div class="tsd-comment tsd-typography"> <p>This is true if all invocations of the given predicate on items in the collection are true.</p> <p>Call the given predicate on each item in the collection. As soon as a call returns false, this returns false. Otherwise this returns true. For an empty collection this returns true.</p> <p>This automatically <a href="Iterator.html#reset">reset</a>&#39;s itself when it is called.</p> <dl class="tsd-comment-tags"> <dt>since</dt> <dd><p>1.4</p> </dd> </dl> </div> <h4 class="tsd-parameters-title">Parameters</h4> <ul class="tsd-parameters"> <li> <h5>pred: <span class="tsd-signature-symbol">(</span>x<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">T</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol"> =&gt; </span><span class="tsd-signature-type">boolean</span></h5> <div class="tsd-comment tsd-typography"> <p>This function must not have any side-effects.</p> </div> <ul class="tsd-parameters"> </ul> </li> </ul> <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">boolean</span></h4> <p>True if all predicate calls are true; false otherwise.</p> </li> </ul> </section> <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-interface"> <a name="any" class="tsd-anchor"></a> <h3> <span class="tsd-flag ts-flagVirtual">Virtual</span> any </h3> <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-interface"> <li class="tsd-signature tsd-kind-icon">any<span class="tsd-signature-symbol">(</span>pred<span class="tsd-signature-symbol">: </span><span class="tsd-signature-symbol">(</span>x<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">T</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol"> =&gt; </span><span class="tsd-signature-type">boolean</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">boolean</span></li> </ul> <ul class="tsd-descriptions"> <li class="tsd-description"> <div class="tsd-comment tsd-typography"> <p>This is true if any invocation of the given predicate on items in the collection is true.</p> <p>Call the given predicate on each item in the collection. As soon as a call returns true, this returns true. Otherwise this returns false. For an empty collection this returns false.</p> <p>This automatically <a href="Iterator.html#reset">reset</a>&#39;s itself when it is called.</p> <dl class="tsd-comment-tags"> <dt>since</dt> <dd><p>1.4</p> </dd> </dl> </div> <h4 class="tsd-parameters-title">Parameters</h4> <ul class="tsd-parameters"> <li> <h5>pred: <span class="tsd-signature-symbol">(</span>x<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">T</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol"> =&gt; </span><span class="tsd-signature-type">boolean</span></h5> <div class="tsd-comment tsd-typography"> <p>This function must not have any side-effects.</p> </div> <ul class="tsd-parameters"> </ul> </li> </ul> <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">boolean</span></h4> <p>True if any predicate call is true; false otherwise.</p> </li> </ul> </section> <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-interface"> <a name="each" class="tsd-anchor"></a> <h3> <span class="tsd-flag ts-flagVirtual">Virtual</span> each </h3> <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-interface"> <li class="tsd-signature tsd-kind-icon">each<span class="tsd-signature-symbol">(</span>func<span class="tsd-signature-symbol">: </span><span class="tsd-signature-symbol">(</span>x<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">T</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol"> =&gt; </span><span class="tsd-signature-type">void</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">void</span></li> </ul> <ul class="tsd-descriptions"> <li class="tsd-description"> <div class="tsd-comment tsd-typography"> <p>Call the given function on each item in the collection.</p> <p>This automatically <a href="Iterator.html#reset">reset</a>&#39;s itself when it is called.</p> <dl class="tsd-comment-tags"> <dt>since</dt> <dd><p>1.4</p> </dd> </dl> </div> <h4 class="tsd-parameters-title">Parameters</h4> <ul class="tsd-parameters"> <li> <h5>func: <span class="tsd-signature-symbol">(</span>x<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">T</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol"> =&gt; </span><span class="tsd-signature-type">void</span></h5> <div class="tsd-comment tsd-typography"> <p>This function must not modify the collection.</p> </div> <ul class="tsd-parameters"> </ul> </li> </ul> <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">void</span></h4> <p>this iterator itself</p> </li> </ul> </section> <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-interface tsd-is-overwrite"> <a name="first" class="tsd-anchor"></a> <h3> <span class="tsd-flag ts-flagOverride">Override</span> first </h3> <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-interface tsd-is-overwrite"> <li class="tsd-signature tsd-kind-icon">first<span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">T</span></li> </ul> <ul class="tsd-descriptions"> <li class="tsd-description"> <div class="tsd-comment tsd-typography"> <p>Advance if needed to the first item in the collection and return it, or return null if there is none.</p> <p>Caution: this returns a <em>key/value pair</em>, not a <em>value</em>, for <a href="Map.html">Map</a> iterators.</p> <dl class="tsd-comment-tags"> <dt>since</dt> <dd><p>1.1</p> </dd> </dl> </div> <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">T</span></h4> </li> </ul> </section> <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-interface"> <a name="next" class="tsd-anchor"></a> <h3> next </h3> <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-interface"> <li class="tsd-signature tsd-kind-icon">next<span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">boolean</span></li> </ul> <ul class="tsd-descriptions"> <li class="tsd-description"> <div class="tsd-comment tsd-typography"> <p>Call this method to advance the iterator to the next item in the collection. This should be called before accessing any <a href="Iterator.html#value">value</a>.</p> </div> <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">boolean</span></h4> <p>whether another item is available; when true the value of <a href="Iterator.html#value">value</a> will be that item.</p> </li> </ul> </section> <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-interface"> <a name="reset" class="tsd-anchor"></a> <h3> reset </h3> <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-interface"> <li class="tsd-signature tsd-kind-icon">reset<span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">void</span></li> </ul> <ul class="tsd-descriptions"> <li class="tsd-description"> <div class="tsd-comment tsd-typography"> <p>Start this iterator all over again.</p> </div> <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">void</span></h4> </li> </ul> </section> </section> </div> <div class="col-4 col-menu menu-sticky-wrap menu-highlight"> <nav class="tsd-navigation primary"> <ul> <li class=" "> <a href="../index.html">GoJS <wbr>Class <wbr>Index</a> </li> </ul> </nav> <nav class="tsd-navigation secondary menu-sticky"> <ul class="before-current"> </ul> <ul class="current"> <li class="current tsd-kind-interface tsd-has-type-parameter"> <a href="Iterator.html" class="tsd-kind-icon">Iterator</a> <ul> <li class=" tsd-kind-property tsd-parent-kind-interface tsd-is-overwrite"> <a href="Iterator.html#count" class="tsd-kind-icon">count</a> </li> <li class=" tsd-kind-property tsd-parent-kind-interface tsd-is-overwrite"> <a href="Iterator.html#iterator" class="tsd-kind-icon">iterator</a> </li> <li class=" tsd-kind-property tsd-parent-kind-interface"> <a href="Iterator.html#key" class="tsd-kind-icon">key</a> </li> <li class=" tsd-kind-property tsd-parent-kind-interface"> <a href="Iterator.html#value" class="tsd-kind-icon">value</a> </li> <li class=" tsd-kind-method tsd-parent-kind-interface"> <a href="Iterator.html#all" class="tsd-kind-icon">all</a> </li> <li class=" tsd-kind-method tsd-parent-kind-interface"> <a href="Iterator.html#any" class="tsd-kind-icon">any</a> </li> <li class=" tsd-kind-method tsd-parent-kind-interface"> <a href="Iterator.html#each" class="tsd-kind-icon">each</a> </li> <li class=" tsd-kind-method tsd-parent-kind-interface tsd-is-overwrite"> <a href="Iterator.html#first" class="tsd-kind-icon">first</a> </li> <li class=" tsd-kind-method tsd-parent-kind-interface"> <a href="Iterator.html#next" class="tsd-kind-icon">next</a> </li> <li class=" tsd-kind-method tsd-parent-kind-interface"> <a href="Iterator.html#reset" class="tsd-kind-icon">reset</a> </li> </ul> </li> </ul> <ul class="after-current"> </ul> </nav> </div> </div> </div> <div class="tsd w-full max-w-screen-xl mx-auto px-2"> <div class="bottom-copyright">Copyright &copy; 1998-2021 by Northwoods Software Corporation.</div> </div> <div class="overlay"></div> <script src="../assets/js/main.js"></script> <script async src="https://www.googletagmanager.com/gtag/js?id=UA-1506307-5"></script> <script> window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'UA-1506307-5'); var getOutboundLink = function(url, label) { gtag('event', 'click', { 'event_category': 'outbound', 'event_label': label, 'transport_type': 'beacon' }); } // topnav var topButton = document.getElementById("topnavButton"); var topnavList = document.getElementById("topnavList"); topButton.addEventListener("click", function() { this.classList.toggle("active"); topnavList.classList.toggle("hidden"); document.getElementById("topnavOpen").classList.toggle("hidden"); document.getElementById("topnavClosed").classList.toggle("hidden"); }); </script> </body> </html>