This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const objeto = { }; | |
| objeto.chave_qualquer = 'valor_qualquer'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const objeto = { }; | |
| objeto['chave_qualquer'] = 'valor_qualquer'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function funcaoMisteriosaQueObtemOIteratorDeUmArray(array) { | |
| const funcaoQueConstroiUmIterator = array[Symbol.iterator]; | |
| return funcaoQueConstroiUmIterator(); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const array = [1, 2, 3]; | |
| const iterator = funcaoMisteriosaQueObtemOIteratorDeUmArray(array); | |
| let iteratorResult = iterator.next(); | |
| while (!iteratorResult.done) { | |
| console.log(iteratorResult.value); // Vai imprimir 1, 2 e 3 | |
| iteratorResult = iterator.next(); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const array = [1, 2, 3]; | |
| const iterator = funcaoMisteriosaQueObtemOIteratorDeUmArray(array); | |
| iterator.next(); // { done: false, value: 1 } | |
| iterator.next(); // { done: false, value: 2 } | |
| iterator.next(); // { done: false, value: 3 } | |
| iterator.next(); // { done: true, value: undefined } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const array = [1, 2, 3]; | |
| for (let elemento of array) { | |
| console.log(elemento); // Vai imprimir 1, 2 e 3 | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| O for..of funciona através da invocação da função identificada por Symbol.iterator (um símbolo único) | |
| de um objeto: | |
| const it = objeto[Symbol.iterator](); | |
| No caso, it é um objeto que possui uma função next() que retorna um contrato assim: | |
| { | |
| value: 'some value', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <bits/stdc++.h> | |
| using namespace std; | |
| struct edge { | |
| size_t a, b; | |
| int weight; | |
| }; | |
| struct edge_comparator { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <bits/stdc++.h> | |
| using namespace std; | |
| class unionfind { | |
| private: | |
| size_t _n; | |
| size_t *_nodes; | |
| size_t *_sizes; | |
| size_t root(size_t n); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.net.URLClassLoader; | |
| import java.net.URL; | |
| import java.net.MalformedURLException; | |
| import java.lang.ClassNotFoundException; | |
| import java.io.File; | |
| public class Programa { | |
| public static void main(String[] args) throws ClassNotFoundException, MalformedURLException { | |
| URL[] bin = { new File(".").toURI().toURL() }; |