Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
bin_heap.h
Package: leda.tar.gz [view]
Upload User: gzelex
Upload Date: 2007-01-07
Package Size: 707k
Code Size: 2k
Category:
Mathimatics-Numerical algorithms
Development Platform:
MultiPlatform
- /*******************************************************************************
- +
- + LEDA-R 3.2.3
- +
- + bin_heap.h
- +
- + Copyright (c) 1995 by Max-Planck-Institut fuer Informatik
- + Im Stadtwald, 66123 Saarbruecken, Germany
- + All rights reserved.
- +
- *******************************************************************************/
- #ifndef LEDA_BIN_HEAP_H
- #define LEDA_BIN_HEAP_H
- //------------------------------------------------------------------------------
- // binary Heaps
- //
- // S. Naeher (1993)
- //
- //------------------------------------------------------------------------------
- #include <LEDA/basic.h>
- class bin_heap_elem
- {
- friend class bin_heap;
- GenPtr key;
- GenPtr inf;
- int index;
- bin_heap_elem(GenPtr k, GenPtr i, int pos) { key = k; inf = i; index = pos; }
- LEDA_MEMORY(bin_heap_elem)
- };
- typedef bin_heap_elem* bin_heap_item;
- class bin_heap {
- virtual int cmp(GenPtr, GenPtr) const { return 0; }
- virtual void copy_key(GenPtr&) const {}
- virtual void copy_inf(GenPtr&) const {}
- virtual void clear_key(GenPtr&) const {}
- virtual void clear_inf(GenPtr&) const {}
- virtual void print_key(GenPtr) const {}
- virtual void print_inf(GenPtr) const {}
- virtual int int_type() const { return 0; }
- int count;
- int max_size;
- bin_heap_item* HEAP;
- void rise(int,bin_heap_item);
- void sink(int,bin_heap_item);
- protected:
- bin_heap_item item(GenPtr p) const { return bin_heap_item(p); }
- public:
- bin_heap_item insert(GenPtr, GenPtr);
- bin_heap_item find_min() const { return HEAP[1]; }
- bin_heap_item first_item() const { return HEAP[1]; }
- bin_heap_item next_item(bin_heap_item it) const { return HEAP[it->index+1];}
- void decrease_key(bin_heap_item, GenPtr);
- void change_inf(bin_heap_item, GenPtr);
- void del_item(bin_heap_item);
- void del_min() { del_item(find_min()); }
- GenPtr key(bin_heap_item it) const { return it->key; }
- GenPtr inf(bin_heap_item it) const { return it->inf; }
- int size() const { return count; }
- bool empty() const { return count==0; }
- void clear();
- void print();
- bin_heap& operator=(const bin_heap&);
- bin_heap(int n = 1024); // default start size
- bin_heap(const bin_heap&);
- bin_heap(int,int) {}
- virtual ~bin_heap();
- };
- #endif