[Ndn-interest] Problem with Interest and Data structure in c++
Matteo Bertolino
Matteo.Bertolino at eurecom.fr
Tue Sep 20 07:25:41 PDT 2016
Thank you for the advice!
If somebody had a similar problem, here there is my solution:
struct cmpInterests {
bool operator()(const Interest& a, const Interest& b) const {
return a.getName().compare(b.getName());
}
};
std::map<Interest, int, cmpInterests> mappa;
I do not know if it is suitable for my purposes, but at least the
compilation errors are solved.
Sincerely,
Matteo
Quoting Alex Afanasyev <aa at cs.ucla.edu>:
>
>> On Sep 20, 2016, at 9:41 AM, Matteo Bertolino
>> <Matteo.Bertolino at eurecom.fr> wrote:
>>
>> Good morning to all,
>> I write in order to ask your help with a problem.
>> I would like to do a Map <Interest, int>.
>>
>> So I wrote:
>> std::map<Interest, int> mappa;
>> but each operation on it fails, like:
>> int numbEntries = mappa.count(nack.getInterest());
>> or
>> std::map<Interest,int>::iterator it = mappa.find (nack.getInterest());
>> or
>> Interest x: mappa[x] = 5;
>>
>> The error is always the same:
>> /usr/include/c++/4.9/bits/stl_function.h:371:20: error: no match
>> for operator< (operand types are const ndn::Interest and const
>> ndn::Interest)
>> { return __x < __y; }
>>
>> Then I think to redefine operator "<" into interest.cpp, writing:
>> bool
>> operator<(const ndn::Interest ones, const ndn::Interest other)
>> {
>> return ones.getName().compare(other.getName())<0;
>> }
>
> For C++ to find the method, you need to define this operator in the
> same namespace as Interest, e.g.,
>
> namespace ndn {
>
> bool
> operator<(const Interest& i1, const Interest& i2)
> {
> ... // you may need to include additional comparisons in
> addition to checking names
> }
>
> }
>
> ---
> Alex
>
>> But, also here, no effect.
>> Any idea?
>> Thank you,
>> Matteo
>>
>>
>> -------------------------------------------------------------------------------
>> This message was sent using EURECOM Webmail: http://webmail.eurecom.fr
>>
>>
>> _______________________________________________
>> Ndn-interest mailing list
>> Ndn-interest at lists.cs.ucla.edu
>> http://www.lists.cs.ucla.edu/mailman/listinfo/ndn-interest
>
>
-------------------------------------------------------------------------------
This message was sent using EURECOM Webmail: http://webmail.eurecom.fr
More information about the Ndn-interest
mailing list