473,804 Members | 2,787 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

comparison deal with vector

1 New Member
hey,

is there anyone who know how to deal with vector?
i have 2 files as below:
Expand|Select|Wrap|Line Numbers
  1. file1.doc
  2. ::component
  3. list
  4. ::Start 
  5. green[2:0] in grp1 
  6. blue in grp2
  7. orange[3:0] in grp3
  8. red[4:0] in grp5
  9. yellow in grp4
  10. ::End 
  11. Lab
  12. ::Engineering
  13.  
  14. ____________________________________________________
  15.  
  16. file1_fast.txt
  17. dont_touch : true ;
  18. area : 1 ;
  19. _power : 0.000 ;
  20. direction : inout ;
  21. capacitance : 123.456 ;
  22. /* automatically added to prevent m < errors */
  23. capacitance : 29.7 ;
  24. }
  25. name(green1) {
  26. direction : input ;
  27. capacitance : 14.370 ;
  28. }
  29. name(blue) {
  30. direction : input ;
  31. capacitance : 432;
  32. }
  33. name(green2) {
  34. direction : input ;
  35. capacitance : 14.370 ;
  36. }
  37. name(yellow) {
  38. direction : input ;
  39. capacitance : 432;
  40. }
  41. name(orange1) {
  42. direction : input ;
  43. capacitance : 15.5 ;
  44. }
  45. direction : input ;
  46. capacitance : 104 ; 
  47. name(orange2) {
  48. direction : input ;
  49. capacitance : 15.5 ;
  50. }
  51. direction : input ;
  52. capacitance : 104 ; 
  53. }
  54. name(red1) {
  55. direction : input ;
  56. capacitance : 14.370 ;
  57. }
  58. name(red2) {
  59. direction : input ;
  60. capacitance : 432;
  61. }
  62. name(red4) {
  63. direction : input ;
  64. capacitance : 15.5 ;
  65. }
  66. direction : input ;
  67. capacitance : 104 ;
  68. name(red6) {
  69. direction : input ;
  70. capacitance : 14.370 ;
  71. }
  72. name(orange5){
  73. direction : input ;
  74. capacitance : 432;
  75. }
  76. name(orange6) {
  77. direction : input ;
  78. capacitance : 15.5 ;
this mean my file have the following info:
Expand|Select|Wrap|Line Numbers
  1. file1.doc
  2. green1
  3. green2
  4. blue
  5. orange1
  6. orange2
  7. orange3
  8. red1
  9. red2
  10. red3
  11. red4
  12. yellow
  13.  
  14. file1_fast.txt
  15. green1
  16. green2
  17. blue
  18. orange1
  19. orange2
  20. orange5
  21. orange6
  22. yellow
  23. red1
  24. red2
  25. red4
  26. red6 
This is the code to extract the info i wanted and do comparison but the problem is that i do not know how to deal with the vector. can anyone help me please?
Expand|Select|Wrap|Line Numbers
  1. use Data::Dumper;
  2.  
  3. my $doc = '/home/assignment/file1.doc';
  4. my $txt = '/home/assignment/file1_fast.txt';
  5.  
  6.         open my $df, "<", $doc or die "can't open $doc: $!";
  7.         my @listDoc;
  8.         while (<$df>)
  9.         {
  10.                 if (/^::start/../^::start/)
  11.                 {
  12.                         next if /^::/;
  13.                         my ($infoDoc) = split / /;
  14.                         push @listDoc, $infoDoc;
  15.                 }
  16.         }
  17.  
  18.         my %hash;
  19.         open my $ff, "<", $txt or die "Can't open $txt: $!";
  20.         while (my $lineFast = <$ff>)
  21.         {
  22.                 if ($lineFast =~ /name\((\w+)\)/)
  23.                 {
  24.                         $hash{$1}='';
  25.                 }
  26.         }
  27.  
  28.         print Dumper \@listDoc, \%hash;
  29.         print "\n====================\n", join "\n", grep {!exists $hash{$_}} @listDoc;
  30.         print "\n\n";
Jul 19 '07 #1
0 1253

Sign in to post your reply or Sign up for a free account.

Similar topics

10
7261
by: chandra.somesh | last post by:
Hi I recently had to write a small code in a competition ,but my code was rejected cause it failed in 1 of test cases. The problm was .....we are given vector of strings....each string consists of either 1 or 2("12122" 0r "2121" so on..)...i had to find the that string where percentage of '1' is minimum.Now the problem and solution both are trivial but i was told that comparing double with < or > sign doesn't ensure a correct...
2
2063
by: PengYu.UT | last post by:
I'm wonder whether 1. stl directly defined the 6 comparison operators(== != < > <= >=) directly for iterator and const_iterator 2. or it only define == and < and using std::rel_ops to get the other 4 operators. I made the following example for case 1. But I can not make it work. Could you please help me to make it work. Thanks,
2
3707
by: jcteague | last post by:
I have a class that has a set<int> member variable. the items in the set are selected indices of a vector. I would like to sort the set on the values in the vector they point too. Here is a part of the header file: Class A{ public: int getX(int i) //basic getter. gets value from vector private
2
2212
by: news.online.no | last post by:
Hi all Rather than writing std::binary:functions I thought it would be nice to create a comparison expression directly into the algorithm expression. Typical use is struct Person { std::string name () const; };
4
16242
by: Gary Wessle | last post by:
Hi I am writing a code to open a space delimited data file, return the number of rows and columns, as well as return the nth column where n is user define number. I put all the cells in a loooong vector and loop in an incremental way to select the column of choice, here is the code which works but gives a warning ****************************************************************
7
2515
by: Alan | last post by:
Hi. I have programmed in C++ before, but I`m a couple of years out of practice. I am seeking some advice on getting started on a quickie project. . . . I have to read a 54MB text file and do a pairwise comparison among 2500 items or so in the file. Each of those items have to be compared to every other item. Many of the comparison will only require comparing one field of the items. I will probably sort on this field before I do the...
0
2583
by: SvenMathijssen | last post by:
Hi, I've been wrestling with a problem for some time that ought to be fairly simple, but turns out to be very difficult for me to solve. Maybe someone here knows the answer. What I try to do is sort the records in a plain-text index file based on certain columns. The index file consists of records and fields within the records. The individual fields are separated by semicolons, the records by newlines. The index file is loaded into memory...
5
3916
by: fade | last post by:
Good afternoon, I need some advice on the following: I've got a class that has a member std::vector<CStringm_vFileName and a member CString m_path; The vector contains a bunch of filenames with no path included (no C:\...) eg: my_file2.jpg, my_file1.bmp, etc... and m_path stores the path, eg: C:\folder1 I want to sort this vector according to different criterion, such as
1
2089
by: Alan | last post by:
I am wondering if anyone has any better idea of how to approach this problem than I do. . . . I have a vector of items (data). I have to do a pairwise comparison of each item to each other item and apply logic to see if one should be deleted. In the past I have done this using for statements, like: for (int i = 0; i < input_vector.size(); i++) for (int j = i; i < input_vector.size(); j++)
0
9705
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9576
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10568
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9138
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7613
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6847
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5647
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4292
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2988
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.