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
order.c
Package: leda.tar.gz [view]
Upload User: gzelex
Upload Date: 2007-01-07
Package Size: 707k
Code Size: 1k
Category:
Mathimatics-Numerical algorithms
Development Platform:
MultiPlatform
- // This programs is using dictionaries with keys of type "point" with two
- // different linear orders, the lexicographic ordering on the cartesian
- // coordinates (default ordering) and the lexicographic ordering on the
- // polar coordinates.
- // must be linked with libP.a libG.a libL.a -lm !!!
- #include <LEDA/dictionary.h>
- #include <LEDA/plane.h>
- int pol_cmp(point x, point y)
- {
- // defines lexicographic order of the polar coordinates
- point origin(0,0);
- segment sx(origin,x), sy(origin,y);
- int c = compare(sx.angle(), sy.angle()); // predefined compare(double,double)
- if (c) return c;
- return compare(sx.length(),sy.length());
- }
- DEFINE_LINEAR_ORDER(point,pol_cmp,point_pol)
- // Now "point_pol" is equivalent to the data type point
- // with the linear order defined by "pol_cmp".
- main()
- {
- dictionary<point,int> D;
- dictionary<point_pol,int> D_pol;
- point x;
- while (cin >> x)
- { D.insert(x,0);
- D_pol.insert(x,0);
- }
- dic_item it;
- forall_items(it,D) cout << D.key(it) << "n";
- newline;
- forall_items(it,D_pol) cout << D_pol.key(it) << "n";
- newline;
- }