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
| var Subject = function(){ | |
| var self = this; | |
| self.observers = []; | |
| return{ | |
| subscribeObserver:function(observer){ | |
| self.observers.push(observer); | |
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 LinkedList(){ | |
| this.head = null; | |
| this.tail = null; | |
| } | |
| function Node(value, next, prev){ | |
| this.value = value; | |
| this.next = next; | |
| this.prev = prev; | |
| } |
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
| // Singleton design pattern ES5 | |
| var Singleton = (function(){ | |
| var instant; | |
| function createInstant(){ | |
| var object = new Object("Iam instant"); | |
| return object; | |
| } | |
| return { | |
| getInstant:function(){ | |
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 BST(value){ | |
| this.value = value; | |
| this.left = null; | |
| this.right = null; | |
| } | |
| BST.prototype.insert = function(value){ | |
| if(value <= this.value){ | |
| if(!this.left) this.left = new BST(value); | |
| else this.left.insert(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
| function HashTable (size){ | |
| this.buckets = Array(size); | |
| this.numBuckets = this.buckets.length; | |
| } | |
| function HashNode(key, value, next){ | |
| this.key = key; | |
| this.value = value; | |
| this.next = next || null; | |
| } |
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
| void main() { | |
| var deck = new Deck(); | |
| deck.shuffle(); | |
| deck.deal(5); | |
| print(deck.deal(5)); | |
| } | |
| class Deck { | |
| List<Card> cards = []; |
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 'dart:async'; | |
| import 'package:flutter/material.dart'; | |
| import 'package:provider/provider.dart'; | |
| void main() => runApp(MyApp()); | |
| class MyApp extends StatelessWidget { | |
| @override | |
| Widget build(BuildContext context) { | |
| const appTitle = 'StreamProvider Demo'; |
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 'dart:async'; | |
| import 'package:flutter/material.dart'; | |
| import 'package:provider/provider.dart'; | |
| void main() => runApp(MyApp()); | |
| class CountDown extends ValueNotifier<int> { | |
| CountDown(int downFrom) : super(downFrom) { | |
| scheduleDecrement(); | |
| } |