Sponsored Content
Top Forums Programming STL Iterator and user-defined class Post 302343184 by johnbach on Wednesday 12th of August 2009 12:47:46 AM
Old 08-12-2009
Thanks for your time in explaining me with an example.
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Nawk user-defined function

HELP!!!! I am in an on-line shell programming class and have a question. Here is the data: Mike Harrington:(510) 548-1278:250:100:175 Christian Dobbins:(408) 538-2358:155:90:201 Susan Dalsass:(206) 654-6279:250:60:50 (There are 12 contribuors total) This database contains names, phone... (1 Reply)
Discussion started by: NewbieGirl
1 Replies

2. AIX

User defined signal 1

Hi, I am just running a incremental back-up on one of my server. But these days It abrubtly fails with below error. ========== User defined signal 1 =========== When I rerun the back-up, It completed successfully.Earlier this was not happening. Any Idea, what could be the problem... (0 Replies)
Discussion started by: nitesh_raj
0 Replies

3. UNIX for Dummies Questions & Answers

User defined service

I want to add a new IP service which executes a script on SCO OS5. I have amended /etc/services and added to port number (3333) I have amended /etc/inetd.conf and added a line for this service but I can't get it to execute my own shell script When I telnet to the IP address on port 3333 I... (1 Reply)
Discussion started by: markdrury
1 Replies

4. Shell Programming and Scripting

need help with User Defined Function

Dear Friends, I need a help regarding User defined function in shell script. My problem is as follows: my_func.sh my_funcI(){ grep 'mystring' I.dat } my_funcQ(){ grep 'mystring' Q.dat } myfuncI myfuncQ But As both the function has same function only the... (11 Replies)
Discussion started by: user_prady
11 Replies

5. Solaris

Wants to use User defined Macro in Makefile

I am converting 32-bit C++ code to 64-bit on Solaris. I have used unsigned long in number of files. I want it to convert to unsigned int for 64-bit. Total files are around 2000. Can you please help me if possible to do it in makefile using MACRO while build. If it is not possible any other... (2 Replies)
Discussion started by: amit_27
2 Replies

6. Programming

add more user-defined signals

Hi Is there a way to add more user-defined signals? I am currently using SIGUSR1 and SIGUSR2 - but I need another one. How can I do that? Thanks! (9 Replies)
Discussion started by: naamabm
9 Replies

7. Shell Programming and Scripting

User defined functions in awk

Hi; Is der ne to to use user defined functions for the values in awk find $1 -type f -ls | nawk '{{print "|"$3"|"$5"|"$6"|"$8"|"$9"|"$10"|"} for(i=11;i<=NF;i++){printf("%s",$i)}}' In above command i want to append some values returned by user functions on line. thnks; ajay (1 Reply)
Discussion started by: ajaypadvi
1 Replies

8. UNIX for Dummies Questions & Answers

user defined commands

Hi, i would like to create user defined commands. e,g: if an user executes , mkdircd test then a directory called test should be created and it should be cd to test. How i can create the command mkdircd with below action: mkdir $1 && cd $1. Please help me in achieving this (7 Replies)
Discussion started by: pandeesh
7 Replies

9. UNIX for Dummies Questions & Answers

Problem syntax with user-defined function

Hi ! I got a script from Arabic to Roman numeral conversion - .comp.lang.awk, that I would like to modify to apply it on my input file. input ("|"-delimited fields): AAAAAA|1, 10, 13, 14, 25, 60 wanted output: AAAAAA|I, X, XIII, XIV, XXV, LX script.awk: #!/usr/bin/gawk -f ... (11 Replies)
Discussion started by: lucasvs
11 Replies
FBB::binary_search(3bobcat)				      Binary search function				       FBB::binary_search(3bobcat)

NAME
FBB::binary_search - Extensions to the STL binary_search function template SYNOPSIS
#include <bobcat/binarysearch> DESCRIPTION
The FBB::binary_search function templates extend the STL binary_search function template returning an iterator to the element found, instead of a bool value informing the caller whether or not the searched for element is present in a provided iterator range. The bool value returned by the STL binary_search function template is often not the kind of information the caller of the function is interested in. Rather, the caller will often want to use binary_search in the way find_if is used: returning an iterator to the found ele- ment or returning the end-iterator if the element was not found. Whereas find_if does not require the elements in the iterator range to be sorted, and thus will use a linear search binary_search may use the sorted nature of the elements to its advantage, using a binary search algorithm requiring 2 log N iterations to locate the searched for element rather than (on average) N/2 iterations. The FBB::binary_search algorithm uses this binary searching process while at the same time allowing its use like find_if. Since the FBB::binary_search function templates use the same number and types of parameters as the stl::binary_search function templates the explicit use of the FBB namespace will often be required in situations where both function templates are made available to the com- piler. NAMESPACE
FBB All constructors, members, operators and manipulators, mentioned in this man-page, are defined in the namespace FBB. INHERITS FROM
- OVERLOADED FUNCTIONS
In the following description several template type parameters are used. They are: o Iterator represents an iterator type; o Type represents a value of the type to which Iterator points. o Comparator represents a comparator function or class type object which was used to sort the elements to which the Iterator range refer; o Iterator binary_search(Iterator begin, Iterator end, Type const &value): Using a binary search algorithm value is searched for in the range of elements referred to by the provided iterator range. If the value is found an iterator pointing to this value is returned, otherwise end is returned. The elements in the range must have been sorted by the Type::operator<() function. o Iterator binary_search(Iterator begin, Iterator end, Type const &value, Comparator comparator): Using a binary search algorithm value is searched for in the range of elements referred to by the provided iterator range. If the value is found an iterator pointing to this value is returned, otherwise end is returned. The elements and the provided value are compared using comparator(*iterator, value) calls, where *iterator refers to an object in the provided iterator range. The elements in the range must have been sorted by the Comparator function or function object. EXAMPLES
#include <iostream> #include <string> #include "../binarysearch" using namespace std; using namespace FBB; string words[] = { "eight", // alphabetically sorted number-names "five", "four", "nine", "one", "seven", "six", "ten", "three", "two" }; class Comparator { public: bool operator()(string const &left, string const &right) const; }; inline bool Comparator::operator()(string const &left, string const &right) const { return left < right; } bool compFun(string const &left, string const &right) { return left < right; } int main() { string *ret = binary_search(words, words + 10, "five"); if (ret != words + 10) cout << "five is at offset " << (ret - words) << endl; ret = binary_search(words, words + 10, "grandpa"); if (ret == words + 10) cout << "grandpa is not the name of a number "; ret = binary_search(words, words + 10, "five", Comparator()); if (ret != words + 10) cout << "five is at offset " << (ret - words) << endl; ret = binary_search(words, words + 10, "grandpa", compFun); // or use: Comparator() if (ret == words + 10) cout << "grandpa is not the name of a number "; return 0; } FILES
bobcat/binarysearch - defines the template functions SEE ALSO
bobcat(7) BUGS
None reported. DISTRIBUTION FILES
o bobcat_3.01.00-x.dsc: detached signature; o bobcat_3.01.00-x.tar.gz: source archive; o bobcat_3.01.00-x_i386.changes: change log; o libbobcat1_3.01.00-x_*.deb: debian package holding the libraries; o libbobcat1-dev_3.01.00-x_*.deb: debian package holding the libraries, headers and manual pages; o http://sourceforge.net/projects/bobcat: public archive location; BOBCAT
Bobcat is an acronym of `Brokken's Own Base Classes And Templates'. COPYRIGHT
This is free software, distributed under the terms of the GNU General Public License (GPL). AUTHOR
Frank B. Brokken (f.b.brokken@rug.nl). libbobcat1-dev_3.01.00-x.tar.gz 2005-2012 FBB::binary_search(3bobcat)
All times are GMT -4. The time now is 07:29 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy