Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums

Go Back   Code Forums > Application and Web Development > Standard C, C++

Reply
 
LinkBack Thread Tools Display Modes
Old 07-06-2005, 10:41 AM   #1 (permalink)
benllera
Registered User
 
Join Date: Jul 2005
Location: Cardiff
Posts: 2
benllera is on a distinguished road
check if a vector equals to a row in a 2D matrix

I have a class template for a 2dimensional matrix (nested std::vector in std::vector) and I need a function that takes a std::vector as argument and checks if it is equal to any row of the matrix.
benllera is offline   Reply With Quote
Old 07-06-2005, 12:05 PM   #2 (permalink)
redhead
Newbie
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,705
redhead is on a distinguished road
How about a loop through your matrix, checking every 2.nd dimension item up against your comparison 2.nd dimesnion item.
Using the bool operator== (const container& c1, const container& c2);, it is described as:
Code:
 Performing a comparison one vector to another takes linear time.
Two `containers` are equal if:

   1. Their size is the same, and
   2. Each member in location i in one vector is equal to the
       member in location i in the other vector.

Comparisons among vectors are done lexicographically.
As described in the C++ reference
It will require a nested loop, but you could do a quick check uppon starting the outer loop, to make sure the item run through the inner loop will allways contain the least items, keeping that as fast as possible.
__________________
Don't worry Ma'am, We're university students, We know what We're doing.
-----
If you pull the pin, Mr.Grenade would no longer be your friend.
-----
01000111 01101111 00100000 01000011 00100000 00100001
redhead is offline   Reply With Quote
Old 07-07-2005, 07:54 AM   #3 (permalink)
benllera
Registered User
 
Join Date: Jul 2005
Location: Cardiff
Posts: 2
benllera is on a distinguished road
Thank you.
benllera is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Row Adding Problems Phantek Everything SQL ( MySQL, MSSQL, DB2, Postgre, Oracle, etc...) 2 05-24-2005 07:13 AM
Row Decrement Phantek Everything SQL ( MySQL, MSSQL, DB2, Postgre, Oracle, etc...) 6 05-20-2005 10:59 AM
javascript: check if file input is undefined sde HTML, XML, Javascript, AJAX 3 03-28-2005 08:15 AM
Pizza Matrix Zenogear11 Lounge 5 05-24-2003 08:34 PM


All times are GMT -8. The time now is 09:34 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting