Svetlin Nakov Telerik Software Academy academy.telerik.com Technical Trainer www.nakov.com Wintellect Power Collections, C 5 Collections.

Slides:



Advertisements
Similar presentations
Transparency No. 1 Java Collection API : Built-in Data Structures for Java.
Advertisements

Lists, Stacks, Queues Svetlin Nakov Telerik Corporation
Dictionaries, Hash Tables, Collisions Resolution, Sets Svetlin Nakov Telerik Corporation
Data Structures and Collections
Computer Science 112 Fundamentals of Programming II Overview of Collections.
Trees, Binary Search Trees, Balanced Trees, Graphs Svetlin Nakov Telerik Corporation
CS 307 Fundamentals of Computer Science 1 Abstract Data Types many slides taken from Mike Scott, UT Austin.
CSSE221: Software Dev. Honors Day 14 Announcements Announcements Pass in Homework 5 now Pass in Homework 5 now Questions on Cars, Trucks, Trains? Questions.
Course Program, Evaluation, Exams, Resources Svetlin Nakov Telerik Software Academy academy.telerik.com Technical Trainer
Java Collections. Collections, Iterators, Algorithms CollectionsIteratorsAlgorithms.
Lists, Stacks, Queues Svetlin Nakov Telerik Corporation
Lists, Stacks, Queues Svetlin Nakov Telerik Corporation
Trees, Tre-Like Structures, Binary Search Trees, Balanced Trees, Tree Traversals, DFS and BFS Svetlin Nakov Telerik Software Academy academy.telerik.com.
Collection types Collection types.
SEG4110 – Advanced Software Design and Reengineering TOPIC G Java Collections Framework.
Overview of Data Structures and Basic Algorithms. Computational Complexity. Asymptotic Notation Svetlin Nakov Telerik Software Academy academy.telerik.com.
FEN 2012UCN Technology - Computer Science 1 Data Structures and Collections Principles revisited.NET: –Two libraries: System.Collections System.Collections.Generics.
1 Hash Tables  a hash table is an array of size Tsize  has index positions 0.. Tsize-1  two types of hash tables  open hash table  array element type.
Data Structures Using C++ 2E
Arrays, Lists, Stacks, Queues Static and Dynamic Implementation Svetlin Nakov Telerik Software Academy academy.telerik.com Technical Trainer
Advanced Tree Structures
Chapter 3 List Stacks and Queues. Data Structures Data structure is a representation of data and the operations allowed on that data. Data structure is.
Java™ How to Program, 9/e Presented by: Dr. José M. Reyes Álamo © Copyright by Pearson Education, Inc. All Rights Reserved.
Course Program, Evaluation, Exams, Resources Telerik Software Academy Data structures and algorithms.
Dictionaries, Hash Tables, Hashing, Collisions, Sets Svetlin Nakov Telerik Software Academy academy.telerik.com Technical Trainer
Big Java Chapter 16.
Collection Data Structures and Libraries
111 © 2002, Cisco Systems, Inc. All rights reserved.
CSS446 Spring 2014 Nan Wang.  Java Collection Framework ◦ Set ◦ Map 2.
Generics Collections. Why do we need Generics? Another method of software re-use. When we implement an algorithm, we want to re-use it for different types.
Object Oriented Programming Ders 10: Data Structures Mustafa Emre İlal
Topic 24 Heaps "You think you know when you can learn, are more sure when you can write even more when you can teach, but certain when you can program."
Multidimensional Arrays, Sets, Dictionaries Processing Matrices, Multidimensional Arrays, Dictionaries, Sets SoftUni Team Technical Trainers Software University.
Data structures and algorithms in the collection framework 1.
Computational Complexity, Choosing Data Structures Svetlin Nakov Telerik Corporation
Standard Template Library The Standard Template Library was recently added to standard C++. –The STL contains generic template classes. –The STL permits.
Interface: (e.g. IDictionary) Specification class Appl{ ---- IDictionary dic; dic= new XXX(); application class: Dictionary SortedDictionary ----
Collections Data structures in Java. OBJECTIVE “ WHEN TO USE WHICH DATA STRUCTURE ” D e b u g.
Computational Complexity of Fundamental Data Structures, Choosing a Data Structure.
Computer Science and Software Engineering University of Wisconsin - Platteville 11.Standard Template Library Yan Shi CS/SE 2630 Lecture Notes.
CSS446 Spring 2014 Nan Wang.  to study trees and binary trees  to understand how binary search trees can implement sets  to learn how red-black trees.
Dictionaries, Hash Tables, Collisions Resolution, Sets Svetlin Nakov Telerik Corporation
Data Structures and Collections Principles.NET: –Two libraries: System.Collections System.Collections.Generics FEN 2014UCN Teknologi/act2learn1 Deprecated.
C++ Review STL CONTAINERS.
1 Principles revisited.NET: Two libraries: System.Collections System.Collections.Generics Data Structures and Collections.
3-1 Java's Collection Framework Another use of polymorphism and interfaces Rick Mercer.
Dictionaries, Hash Tables and Sets Dictionaries, Hash Tables, Hashing, Collisions, Sets SoftUni Team Technical Trainers Software University
SoftUni Team Technical Trainers Software University Trees and Tree-Like Structures Trees, Tree-Like Structures, Binary Search Trees,
Advanced Tree Structures Binary Trees, AVL Tree, Red-Black Tree, B-Trees, Heaps SoftUni Team Technical Trainers Software University
Lists, Stacks, Queues Svetlin Nakov Telerik Software Academy Manager Technical Trainer
Introduction to Java Collection. Java Collections What are they? –A number of pre-packaged implementations of common ‘container’ classes, such as LinkedLists,
CHARLES UNIVERSITY IN PRAGUE faculty of mathematics and physics Advanced.NET Programming I 2 nd Lecture Pavel Ježek
9/27/2016IT 1791 Abstraction A tool (concept) to manage complexity Hide irrelevant details; focus on the features needed Primitive date types are already.
Using the Java Collection Libraries COMP 103 # T2
Data Structures Course Overview SoftUni Team Data Structures
Set Collection A Bag is a general collection class that implements the Collection interface. A Set is a collection that resembles a Bag with the provision.
Fundamentals of Programming II Overview of Collections
Fast String Manipulation
Combining Data Structures
CS240: Advanced Programming Concepts
Road Map CS Concepts Data Structures Java Language Java Collections
Abstract Data Types (ADTs)
14.1 The java.util Package.
Welcome to CSE 143! Go to pollev.com/cse143.
CS2110: Software Development Methods
CS 240 – Advanced Programming Concepts
Chengyu Sun California State University, Los Angeles
Abstract Data Types (ADTs)
Presentation transcript:

Svetlin Nakov Telerik Software Academy academy.telerik.com Technical Trainer Wintellect Power Collections, C 5 Collections

1. Standard.NET Data Structures  Special.NET Collections 2. Wintellect Power Collections  Installation  Power Collection Classes  Implementing Priority Queue 3. C 5 Collections 4. Other Advanced Data Structures  Suffix trees, interval trees, ropes, tries, etc.

Built-In.NET Data Structure Implementations

 Linear structures  Lists: List, LinkedList  Lists: List, LinkedList  Stacks: Stack  Stacks: Stack  Queues: Queue  Queues: Queue  Dictionaries (maps)  Dictionary, SortedDictionary  Dictionary, SortedDictionary  No standard multi-dictionary.NET class  Balanced search tree structures  SortedSet, SortedDictionary  SortedSet, SortedDictionary

 Sets and bags  Sets – HashSet, SortedSet  Sets – HashSet, SortedSet  Bag – no standard.NET class  Ordered sets, bags and dictionaries  Priority queues / heaps  no  Special tree structures  no  Suffix tree, interval tree, index tree, trie  Graphs  no  Directed / undirected, weighted / un-weighted, connected/ non-connected, … 5

6

7

 Collection  Collection  Inheritable IList, virtual Add() / Remove()  ObservableCollection  ObservableCollection  Event CollectionChanged  IReadOnlyCollection  IReadOnlyCollection  Supports only Count and GetEnumerator()  IReadOnlyList  IReadOnlyList  Supports only Count, [] and GetEnumerator()  Concurrent collections (thread-safe)  BlockingCollection, ConcurrentBag, … 8

Live Demo

Open Source C# Implementation of All Major Data Structures: Lists, Sets, Bags, Dictionaries, etc.

 Wintellect Power Collections is powerful open- source data structure library  Download:  Installing Power Collections in Visual Studio  Use NuGet package manager 11

 Bag  Bag  A bag (multi-set) based on hash-table  Unordered collection (with duplicates)  Add / Find / Remove work in time O( 1 )  T should provide Equals() and GetHashCode()  OrderedBag  OrderedBag  A bag (multi-set) based on balanced search tree  Add / Find / Remove work in time O( log(N) )  T should implement IComparable  T should implement IComparable 12

 Set  Set  A set based on hash-table (no duplicates)  Add / Find / Remove work in time O( 1 )  Like.NET’s HashSet  Like.NET’s HashSet  OrderedSet  OrderedSet  A set based on balanced search tree (red-black)  Add / Find / Remove work in time O( log(N) )  Like.NET’s SortedSet  Like.NET’s SortedSet  Provides fast.Range(from, to) operation 13

 MultiDictionary  MultiDictionary  A dictionary (map) implemented by hash-table  Allows duplicates (configurable)  Add / Find / Remove work in time O( 1 )  Like Dictionary >  OrderedDictionary / OrderedMultiDictionary  OrderedDictionary / OrderedMultiDictionary  A dictionary based on balanced search tree  Add / Find / Remove work in time O( log(N) )  Provides fast.Range(from, to) operation 14

 Deque  Deque  Double-ended queue (deque)  BigList  BigList  Editable sequence of indexed items  Like List but provides  Fast Insert / Delete operations (at any position)  Fast Copy / Concat / Sub-range operations  Implemented by the data structure "Rope"  Special kind of balanced binary tree:

Live Demo

 What is a "priority queue"?  Data structure to efficiently support finding the item with the highest priority  Like a queue, but with priorities  The basic operations  Enqueue(T element)  Dequeue()  T  There is no build-in priority queue in.NET  See the data structure "binary heap" binary heapbinary heap  Can be implemented also by OrderedBag  Can be implemented also by OrderedBag

class PriorityQueue where T : IComparable class PriorityQueue where T : IComparable { private OrderedBag queue; private OrderedBag queue; public int Count public int Count { get { return this.queue.Count; } get { return this.queue.Count; } } public PriorityQueue() public PriorityQueue() { this.queue = new OrderedBag (); this.queue = new OrderedBag (); } public void Enqueue(T element) public void Enqueue(T element) { this.queue.Add(element); this.queue.Add(element); } public T Dequeue() public T Dequeue() { return this.queue.RemoveFirst(); return this.queue.RemoveFirst(); }} 18

Live Demo

Suffix Trees, Interval Trees, Tries, Ropes, Heaps, …

 Suffix tree (position tree)  Represents the suffixes of given string  Used to implement fast search in string  Trie (prefix tree)  Special tree structure used for fast multi-pattern matching  Rope  Balanced tree structure for indexed items with fast inserts / delete  Allows fast string edit operations 21

 Interval tree  Keeps intervals [a…b] in ordered balanced tree  Allows to efficiently find all intervals that overlap with any given interval or point  Binary heap, Fibonacci heap  Special tree-like data structures to efficiently implement a priority queue  Index trees  Used to keep sorted indices of database records  B-tree, B+ tree, T-tree 22

Open Source Generic Collection Library for C#

 What are "C 5 Collections"?  C5 Generic Collection Library for C# and CLI  Open-Source Data Structures Library for.NET   Have solid documentation (book) – itu.dk/research/c5/latest/ITU-TR pdf itu.dk/research/c5/latest/ITU-TR pdfhttp://www. itu.dk/research/c5/latest/ITU-TR pdf  The C 5 library defines its own interfaces like IEnumerable, IIndexed, IIndexedSorted, etc. 24

25

 Classical collection classes  ArrayList, LinkedList, CircularQueue, HashSet, TreeSet, HashBag, TreeBag  ArrayList, LinkedList, CircularQueue, HashSet, TreeSet, HashBag, TreeBag  HashedArrayList  HashedArrayList  Combination of indexed list + hash-table  Fast Add / Find / indexer []  O( 1 )  IntervalHeap  IntervalHeap  Efficient double-ended priority queue 26

Questions?

1. Implement a class PriorityQueue based on the data structure "binary heap". 2. Write a program to read a large collection of products (name + price) and efficiently find the first 20 products in the price range [a…b]. Test for products and price searches. Hint: you may use OrderedBag and sub-ranges. 3. Write a program that finds a set of words (e.g words) in a large text (e.g. 100 MB text file). Print how many times each word occurs in the text. Hint: you may find a C# trie in Internet.

 C# Telerik Academy  csharpfundamentals.telerik.com csharpfundamentals.telerik.com  Telerik Software Academy  academy.telerik.com academy.telerik.com  Telerik Facebook  facebook.com/TelerikAcademy facebook.com/TelerikAcademy  Telerik Software Academy Forums  forums.academy.telerik.com forums.academy.telerik.com