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
list.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
- #include <LEDA/list.h>
- #include <LEDA/stream.h>
- int cmp_inv(const string& x, const string& y) { return compare(y,x); }
- int cmp_length(const string& x, const string& y)
- { return x.length() - y.length(); }
- int ord(const string& x) { return (x.length() > 0) ? int(x[0]) : 0;}
- void upper_case(string& x)
- { int d = 'A' - 'a';
- for(int i=0; i<x.length(); i++)
- if (x[i] >= 'a' && x[i] <= 'z') x[i] += d;
- }
- main()
- {
- string fname = read_string("file: ");
- list<string> L;
- if (fname == "cin")
- L.read("L = ");
- else
- L.read(file_istream(fname),EOF);
- L.permute();
- // sort lexicographically
- L.sort(); // compare(string,string) used
- L.print("sorted lexicographically:n",'n');
- newline;
- newline;
- // sort decreasing
- L.sort(cmp_inv);
- L.print("sorted decrasing:n",'n');
- newline;
- newline;
- // sort by length
- L.sort(cmp_length);
- L.print("sorted by length:n",'n');
- newline;
- newline;
- // bucket_sort by first character
- L.bucket_sort(0,255,ord);
- L.print("sorted by s[0]:n",'n');
- newline;
- newline;
- // turn characters to upper case
- L.apply(upper_case);
- L.print("upper case:n",'n');
- newline;
- newline;
- cout << "used memory = " << used_memory() << " bytesn";
- return 0;
- }