Пример #1
0
void CameraGroup::parse (std::string fn)
{
  read_xml (fn, pt);

  auto p = pt.get_child ("PropertyList.sim.rendering.camera-group");

  auto wp = p.equal_range ("window");
  for (auto wi = wp.first; wi != wp.second; wi++) {
    Window w (wi->second);
    windows.insert (std::pair <std::string, Window>(w.name(), w));
  }

  auto cp = p.equal_range ("camera");
  for (auto ci = cp.first; ci != cp.second; ci++) {
    Camera c (*this, ci->second);
    cameras.insert (std::pair <std::string, Camera>(c.name(), c));
  }

  for (auto i = cameras.begin(); i != cameras.end(); i++) {
    Camera &c = i->second;
    c.push_facets (triangles);
  }

  m_tree = new Tree (triangles.begin(),triangles.end());
}
Пример #2
0
void BaseApp::SetMatchesFromTracks(int img1, int img2)
{
    std::vector<int> &tracks1 = m_image_data[img1].m_visible_points;
    std::vector<int> &tracks2 = m_image_data[img2].m_visible_points;

    std::vector<int> isect = GetVectorIntersection(tracks1, tracks2);
    
    int num_isect = (int) isect.size();

    if (num_isect == 0)
        return;
    
    MatchIndex idx = GetMatchIndex(img1, img2);

    std::vector<KeypointMatch> &matches = m_matches.GetMatchList(idx); 
    // m_match_lists[idx];

    matches.clear();
    matches.resize(num_isect);

    for (int i = 0; i < num_isect; i++) {
        int tr = isect[i];

#if 0
        int num_views = (int) m_track_data[tr].m_views.size();
        int k1 = -1, k2 = -1;

        for (int j = 0; j < num_views; j++) {
            if (m_track_data[tr].m_views[j].first == img1) {
                k1 = m_track_data[tr].m_views[j].second;
            } 

            if (m_track_data[tr].m_views[j].first == img2) {
                k2 = m_track_data[tr].m_views[j].second;
            } 
        }

        assert(k1 != -1 && k2 != -1);
#endif

        std::pair<std::vector<int>::const_iterator, 
            std::vector<int>::const_iterator> p;
        const std::vector<int> &pt1 = m_image_data[img1].m_visible_points;
        p = equal_range(pt1.begin(), pt1.end(), tr);
        assert(p.first != p.second);
        int offset = p.first - pt1.begin();
        int k1 = m_image_data[img1].m_visible_keys[offset];

        const std::vector<int> &pt2 = m_image_data[img2].m_visible_points;
        p = equal_range(pt2.begin(), pt2.end(), tr);
        assert(p.first != p.second);
        offset = p.first - pt2.begin();
        int k2 = m_image_data[img2].m_visible_keys[offset];

        matches[i] = KeypointMatch(k1, k2);
    }
}
Пример #3
0
// In its own function because compilers differ in selecting const/nonconst
// members where no choice is needed.
//
static void TestEqualRange (rcintvec_t v)
{
    pair<intiter_t,intiter_t> rv;
    rv = equal_range (v, 10);
    cout.format ("Range of  10 is { %2zd, %2zd }\n", abs_distance (v.begin(), rv.first), abs_distance (v.begin(), rv.second));
    rv = equal_range (v, 0);
    cout.format ("Range of   0 is { %2zd, %2zd }\n", abs_distance (v.begin(), rv.first), abs_distance (v.begin(), rv.second));
    rv = equal_range (v, 100);
    cout.format ("Range of 100 is { %2zd, %2zd }\n", abs_distance (v.begin(), rv.first), abs_distance (v.begin(), rv.second));
}
Пример #4
0
static void test34_common(const char *testname)
{
	auto m=map_t::create();

	auto v=LIBCXX_NAMESPACE::ref<valueObj>::create();

	{
		auto mcguffin=m->insert(std::make_pair(0, v));

		std::cout << testname << "insert mcguffin null: "
			  << mcguffin.null() << std::endl;

		for (const auto &v:*m)
		{
			std::cout << testname << "key " << v.first
				  << std::flush
				  << " value: " << v.second.getptr()->v_proof
				  << std::endl;
			v.second.erase();

			std::cout << testname << "key " << v.first
				  << " after remove, null: "
				  << v.second.getptr().null()
				  << std::endl;
		}
		for (const auto &v:*m)
		{
			std::cout << testname << "key " << v.first
				  << " shouldn't be here." << std::endl;
		}
	}

	{
		auto mcguffin=(*m)[0]=v;

		std::cout << testname << "size is " << m->size() << std::endl;
		if (m->find(0) == m->end())
			std::cout << "find(0) equal to end()"
				  << std::endl;
		for (const auto &v:*m)
		{
			std::cout << testname << "key " << v.first
				  << std::flush
				  << " value: " << v.second.getptr()->v_proof
				  << std::endl;
		}
	}
	std::cout << testname << "size is " << m->size() << std::endl;

	for (const auto &v:*m)
	{
		std::cout << testname << "ghost key " << v.first
			  << std::flush
			  << " value: " << v.second.getptr()->v_proof
			  << std::endl;
	}

	m->count(0);
	m->equal_range(0);
}
Пример #5
0
	double CSR::operator () (size_t row, size_t col) {
		std::pair<std::vector<size_t>::iterator, std::vector<size_t>::iterator> col_index
			= equal_range(col_indices.begin() + row_ptrs[row], col_indices.begin() + row_ptrs[row + 1], col);;
		if(col_index.first == col_index.second)
			return 0;
		return values[col_index.first - col_indices.begin()];
	}
Пример #6
0
int main() {
    std::multimap<std::string, std::string> map = {
       {"A", "a1"}, {"A", "a2"}, {"B", "b"}
    };
    
    // Goal: Replace the two elements with the key "A" with another, single, value
    
    // Method 1 - Erase all and emplace
    // Advantages: simple and intuitive
    // Disadvantages: two lookups for erase and emplace
    auto map1 = map;
    map1.erase("A");
    map1.emplace("A", "a");
    print(map1);
    
    // Method 2 - Replace one of the existing elements and erase the rest;
    //              emplace if key doesn't exist
    // Advantages: only one lookup (equal_range) and no additional allocation
    //              when elements already exist
    // Disadvantage: much more complex
    auto map2 = map;
    auto range = map2.equal_range("A");
    if(range.first != map2.end()) {
        range.first->second = "a";
        map2.erase(++range.first, range.second);
    }
    else {
        map2.emplace("A", "a");
    }
    print(map2);
}
Пример #7
0
size_t count_of_equals(iterator_t const& begin,
        iterator_t const& end,
        typename iterator_t::value_type elem)
{
    auto range = equal_range(begin, end, elem);
    return range.second - range.first;
}
Пример #8
0
void test_hash_table_builder() {
    const size_t N = 1024 * 1024;
    std::vector<uint8_t> string;
    for (unsigned n = 0; string.size() < N; n++) {
        string.push_back(n);
        const std::vector<uint8_t> cpy = string;
        string.insert(string.end(), cpy.begin(), cpy.end());
    }
    printf("%d\n", (int)string.size());

    const size_t threshold = 80 * 1024;
    auto table = matcher_t::init_string_hashes(string.data(), string.size(), threshold);
    size_t tt = 0;
    for (const uint8_t *p = string.data(); p + threshold < string.data() + string.size(); p++) {
        const uint32_t hash = calculate_adler_hash(p, threshold).get_value();
        auto matching_indexes = table.equal_range(hash);
        VERIFY(matching_indexes.first != matching_indexes.second);
        auto i_found = std::find_if( matching_indexes.first, matching_indexes.second, 
            [&](auto i){ return i.second == (p - string.data()); } );
        VERIFY(i_found != matching_indexes.second);
        if (p  > tt + string.data()) {
            printf(".");
            tt += string.size() / 200;
        }
    }
    printf("\n");
}
Пример #9
0
bool GeneralName::matches_dn(const std::string& nam) const
   {
   std::stringstream ss(nam);
   std::stringstream tt(name());
   X509_DN nam_dn, my_dn;

   ss >> nam_dn;
   tt >> my_dn;

   auto attr = nam_dn.get_attributes();
   bool ret = true;
   int trys = 0;

   for(const std::pair<OID,std::string>& c: my_dn.get_attributes())
      {
      auto i = attr.equal_range(c.first);

      if(i.first != i.second)
         {
         trys += 1;
         ret &= i.first->second == c.second;
         }
      }

   return trys > 0 && ret;
   }
void
DbConstIndex::performQuery(const DbQueryKey &queryKey,
	DbIndexIterator &begin, DbIndexIterator &end) const
{
	DbKeyComparator cmp(queryKey);
	
	switch (queryKey.mOp) {
	
	case CSSM_DB_EQUAL:
		{
			pair<DbIndexIterator, DbIndexIterator> result;
			result = equal_range(mKeyOffsetVector.begin(), mKeyOffsetVector.end(),
				DbKeyComparator::kUseQueryKeyOffset, cmp);
			begin = result.first;
			end = result.second;
		}
		break;
		
	case CSSM_DB_LESS_THAN:
		begin = mKeyOffsetVector.begin();
		end = lower_bound(begin, mKeyOffsetVector.end(),
				DbKeyComparator::kUseQueryKeyOffset, cmp);
		break;
		
	case CSSM_DB_GREATER_THAN:
		end = mKeyOffsetVector.end();
		begin = lower_bound(mKeyOffsetVector.begin(), end,
				DbKeyComparator::kUseQueryKeyOffset, cmp);
		break;
		
	default:
		CssmError::throwMe(CSSMERR_DL_INTERNAL_ERROR);
		break;
	}
}
Пример #11
0
UInt32 Archive::find_dir(const wstring& path) {
  if (file_list.empty())
    make_index();

  ArcFileInfo dir_info;
  dir_info.is_dir = true;
  dir_info.parent = c_root_index;
  size_t begin_pos = 0;
  while (begin_pos < path.size()) {
    size_t end_pos = begin_pos;
    while (end_pos < path.size() && !is_slash(path[end_pos])) end_pos++;
    if (end_pos != begin_pos) {
      dir_info.name.assign(path.data() + begin_pos, end_pos - begin_pos);
      FileIndexRange fi_range = equal_range(file_list_index.begin(), file_list_index.end(), -1, [&] (UInt32 left, UInt32 right) -> bool {
        const ArcFileInfo& fi_left = left == -1 ? dir_info : file_list[left];
        const ArcFileInfo& fi_right = right == -1 ? dir_info : file_list[right];
        return fi_left < fi_right;
      });
      if (fi_range.first == fi_range.second)
        FAIL(HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND));
      dir_info.parent = *fi_range.first;
    }
    begin_pos = end_pos + 1;
  }
  return dir_info.parent;
}
Пример #12
0
          class _Compare, class _Alloc> __size_type__ 
_Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc> ::count(const _Key& __k) const
{
  pair<const_iterator, const_iterator> __p = equal_range(__k);
  size_type __n = distance(__p.first, __p.second);
  return __n;
}
Пример #13
0
typename RangeT::size_type List< RangeT, TraitsT, ContainerT >::erase(const RangeT& value)
{
	if ( value.end() > limit() )
	{
//		throw ListException( value, limit() );
		CString msg;
		msg.Format( _T( "ListError - erase - size: %u - limit: %I64u - sum: %I64u - " )
			_T( "Range - begin: %I64i - end: %I64u" ),
			size(), limit(), Traits::length_sum(), value.begin(), value.end() );
		theApp.Message( MSG_ERROR, msg );
		return 0;
	}
	if ( value.size() == 0 ) return 0;
	iterator_pair sequence( equal_range( value ) );
	if ( sequence.first == sequence.second ) return 0;
	const range_type front( min( sequence.first->begin(), value.begin() ),
		value.begin(), value.value() );
	const range_type back( value.end(),
		max( ( --sequence.second )->end(), value.end() ), value.value() );
	range_size_type sum = 0;
	for ( ++sequence.second; sequence.first != sequence.second; ) sum += erase( sequence.first++ );
	sum -= insert( sequence.second, front );
	sum -= insert( sequence.second, back );
	return sum;
}
Пример #14
0
WordSPtr WordLibrary::chkExists(wordKey &word, string &senseID){
    WordSRange nextWordS=equal_range(word);
    if(nextWordS.first == nextWordS.second) return 0;
    for(WordSItr wi=nextWordS.first; wi!=nextWordS.second; ++wi) {
        if((*wi).second->senseID==senseID) return (*wi).second;
    }
    return 0;
}
Пример #15
0
		/*!
			This helps the user avoid using the somewhat complex equal_range() interface.
		*/        
        std::vector<Value> Values(const Tag tag) const
        {
			std::pair<const_iterator,const_iterator> P = equal_range(tag);
			std::vector<Value> v;   
			for(const_iterator I=P.first;I!=P.second;I++)
				v.push_back(I->second);
			return v;
        }
Пример #16
0
	int main()
	{
		int ia[] = { 29,23,20,22,17,15,26,51,19,12,35,40 }; 
		vector< int, allocator > ivec( ia, ia+12 );
                ostream_iterator< int >  ofile( cout, " " );

		sort( &ia[0], &ia[12] );

                cout << "array element sequence after sort:\n";
                copy( ia, ia+12, ofile ); cout << "\n\n";

		pair< int*,int* > ia_iter;
		ia_iter = equal_range( &ia[0], &ia[12], 23 );
		
		cout << "equal_range result of search for value 23:\n\t"
		     << "*ia_iter.first: "  << *ia_iter.first << "\t"
		     << "*ia_iter.second: " << *ia_iter.second << "\n\n";
		
		ia_iter = equal_range( &ia[0], &ia[12], 21 );

		cout << "equal_range result of search for absent value 21:\n\t"
		     << "*ia_iter.first: "  << *ia_iter.first << "\t"
		     << "*ia_iter.second: " << *ia_iter.second << "\n\n";
		
		sort( ivec.begin(), ivec.end(), greater<int>() );

                cout << "vector element sequence after sort:\n";
                copy( ivec.begin(), ivec.end(), ofile ); cout << "\n\n";
		
		typedef vector< int, allocator >::iterator iter_ivec;
		pair< iter_ivec, iter_ivec > ivec_iter;

		ivec_iter = equal_range( ivec.begin(), ivec.end(), 26, 
					 greater<int>() );
		
		cout << "equal_range result of search for value 26:\n\t"
		     << "*ivec_iter.first: "  << *ivec_iter.first << "\t"
		     << "*ivec_iter.second: " << *ivec_iter.second << "\n\n";

		ivec_iter = equal_range( ivec.begin(), ivec.end(), 21, 
                                         greater<int>() );

		cout << "equal_range result of search for absent value 21:\n\t"
		     << "*ivec_iter.first: "  << *ivec_iter.first << "\t"
		     << "*ivec_iter.second: " << *ivec_iter.second << "\n\n";
	}
Пример #17
0
double
Curve::multipoint_eval (double x)
{
	pair<ControlList::EventList::const_iterator,ControlList::EventList::const_iterator> range;

	ControlList::LookupCache& lookup_cache = _list.lookup_cache();

	if ((lookup_cache.left < 0) ||
	    ((lookup_cache.left > x) ||
	     (lookup_cache.range.first == _list.events().end()) ||
	     ((*lookup_cache.range.second)->when < x))) {

		ControlEvent cp (x, 0.0);

		lookup_cache.range = equal_range (_list.events().begin(), _list.events().end(), &cp, ControlList::time_comparator);
	}

	range = lookup_cache.range;

	/* EITHER

	   a) x is an existing control point, so first == existing point, second == next point

	   OR

	   b) x is between control points, so range is empty (first == second, points to where
	       to insert x)

	*/

	if (range.first == range.second) {

		/* x does not exist within the list as a control point */

		lookup_cache.left = x;

		if (range.first == _list.events().begin()) {
			/* we're before the first point */
			// return default_value;
			return _list.events().front()->value;
		}

		if (range.second == _list.events().end()) {
			/* we're after the last point */
			return _list.events().back()->value;
		}

		double x2 = x * x;
		ControlEvent* ev = *range.second;

		return ev->coeff[0] + (ev->coeff[1] * x) + (ev->coeff[2] * x2) + (ev->coeff[3] * x2 * x);
	}

	/* x is a control point in the data */
	/* invalidate the cached range because its not usable */
	lookup_cache.left = -1;
	return (*range.first)->value;
}
Пример #18
0
	const_iterator_pair merge_range(const range_type& key) const
	{
		const_iterator_pair sequence( equal_range( key ) );
		if ( sequence.first != m_set.begin() && ( --sequence.first )->end() < key.begin() )
			++sequence.first;
		if ( sequence.second != m_set.end() && sequence.second->begin() == key.end() )
			++sequence.second;
		return sequence;
	}
Пример #19
0
iMidiCtrlVal MidiCtrlValList::findMCtlVal(int tick, Part* part)
{
  MidiCtrlValRange range = equal_range(tick);
  for(iMidiCtrlVal i = range.first; i != range.second; ++i) 
  {
    if(i->second.part == part)
      return i;
  }
  return end();
}
Пример #20
0
iMidiAudioCtrlMap MidiAudioCtrlMap::add_ctrl_struct(int midi_port, int midi_chan, int midi_ctrl_num,  
                                                    const MidiAudioCtrlStruct& macs)
{
  MidiAudioCtrlMap_idx_t h = index_hash(midi_port, midi_chan, midi_ctrl_num);
  std::pair<iMidiAudioCtrlMap, iMidiAudioCtrlMap> range = equal_range(h);
  for(iMidiAudioCtrlMap imacp = range.first; imacp != range.second; ++imacp)
    if(imacp->second.audioCtrlId() == macs.audioCtrlId())
       return imacp;
  return insert(std::pair<MidiAudioCtrlMap_idx_t, MidiAudioCtrlStruct >(h, macs));
}
Пример #21
0
void MidiAudioCtrlMap::erase_ctrl_struct(int midi_port, int midi_chan, int midi_ctrl_num, int audio_ctrl_id)
{
  MidiAudioCtrlMap_idx_t h = index_hash(midi_port, midi_chan, midi_ctrl_num);
  std::pair<iMidiAudioCtrlMap, iMidiAudioCtrlMap> range = equal_range(h);
  MidiAudioCtrlMap macm;
  macm.insert(range.first, range.second);
  for(iMidiAudioCtrlMap imacm = macm.begin(); imacm != macm.end(); ++imacm)
    if(imacm->second.audioCtrlId() == audio_ctrl_id)
       erase(imacm);
}
 int search(int A[], int n, int target) {
     
     if (n <= 0) return -1;
     
     int* p = searchPivot(A, n);
     
     pair<int *, int *> bounds;
     
     bounds = equal_range(A, p+1, target);
     
     if (bounds.first != bounds.second)
         return bounds.first - A;
     
     bounds = equal_range(p+1, A+n, target);
     
     if (bounds.first != bounds.second)
         return bounds.first - A;
     
     return -1;
 }
Пример #23
0
std::list<int> TinyConfig::ListInt(const std::string & key) const
{
    std::pair<const_iterator, const_iterator> ret = equal_range(ModifyKey(key));
    std::list<int> res;

    for(const_iterator
	it = ret.first; it != ret.second; ++it)
	res.push_back(GetInt(it->second));

    return res;
}
Пример #24
0
	range_size_type overlapping_sum(const range_type& key) const
	{
		const_iterator_pair sequence( equal_range( key ) );
		range_size_type sum = 0;
		for ( ; sequence.first != sequence.second; ++sequence.first )
		{
			sum += min( sequence.first->end(), key.end() )
				- max( sequence.first->begin(), key.begin() );
		}
		return sum;
	}
void
exit_handler_intel_x64::unittest_1009_containers_set() const
{
    auto myset = std::set<int>({0, 1, 2, 3});
    auto myset2 = std::set<int>({0, 1, 2, 3});

    auto total = 0;
    for (auto iter = myset.begin(); iter != myset.end(); iter++)
        total += *iter;

    auto rtotal = 0;
    for (auto iter = myset.rbegin(); iter != myset.rend(); iter++)
        rtotal += *iter;

    auto ctotal = 0;
    for (auto iter = myset.cbegin(); iter != myset.cend(); iter++)
        ctotal += *iter;

    auto crtotal = 0;
    for (auto iter = myset.crbegin(); iter != myset.crend(); iter++)
        crtotal += *iter;

    expect_true(total == 6);
    expect_true(rtotal == 6);
    expect_true(ctotal == 6);
    expect_true(crtotal == 6);

    expect_true(myset.size() == 4);
    expect_true(myset.max_size() >= 4);
    expect_false(myset.empty());

    myset.insert(myset.begin(), 0);
    myset.erase(myset.begin());
    myset = myset2;

    myset.swap(myset2);
    myset.swap(myset2);

    myset.emplace();
    myset.emplace_hint(myset.begin());
    myset = myset2;

    myset.key_comp();
    myset.value_comp();

    expect_true(myset.find(0) != myset.end());
    expect_true(myset.count(0) == 1);
    expect_true(myset.lower_bound(0) != myset.end());
    expect_true(myset.upper_bound(0) != myset.end());
    myset.equal_range(0);

    myset.get_allocator();
    myset.clear();
}
Пример #26
0
// Returns all games involving both of the given teams
std::set<Reference<Game>> GameDB::getGames(Reference<Team> team1, Reference<Team> team2) const {
  std::set<Reference<Game>> games;
  auto entry = teamToGames.find(team1);
  if (entry != teamToGames.end()) {
    auto subMap = entry->second;
    auto range = subMap.equal_range(team2);
    for (auto i = range.first; i != range.second; ++i) {
      games.insert(i->second);
    }
  }
  return games;
}
Пример #27
0
int main ()
{
  pair <int*, int*> range(0,0);
  range = equal_range (numbers, numbers + 10, 2);
  cout
    << "2 can be inserted from before index "
    << (range.first - numbers)
    << " to before index "
    << (range.second - numbers)
    << endl;
  return 0;
}
void RealTrafficIPC::
createIDTranslationPackets( const IDPairsToCoords& idPairsToCoords,
                            PacketContainers& idTransReqPackets,
                            IDPairVectors& lowLevelIDPairs ) {
   
   const ItemIDTree& mapIDTree = 
      m_moduleCom.getTopRegionRequest()->getWholeItemIDTree();

   typedef IDPairsToCoords::const_iterator IDsToCoordsIt;

   for ( IDsToCoordsIt it = idPairsToCoords.begin(); 
         it != idPairsToCoords.end(); ++it ) {
      // foreach unique mapID create a IDTranslationRequestPacket with all the 
      // nodes for the map above.
      uint32 overviewMapID = mapIDTree.getHigherLevelMap( it->first.first );
      if ( overviewMapID == MAX_UINT32 || 
           overviewMapID >= FIRST_SUPEROVERVIEWMAP_ID ) {
         continue;
      }
      // find the range for the map we are working on now
      std::pair< IDsToCoordsIt, IDsToCoordsIt > range;
      range = equal_range( idPairsToCoords.begin(), 
                           idPairsToCoords.end(), 
                           *it, 
                           LessFirst() );

      IDPairVector_t idPairs;
      // for all the IDPair_t for the map store them
      for ( IDsToCoordsIt rIt = range.first; rIt != range.second; ++rIt ) {
         idPairs.push_back( rIt->first );
         it = rIt;
      }

      //create the packet that gets the node ids on the map one level up
      auto_ptr< IDTranslationRequestPacket > 
         idPacket( new IDTranslationRequestPacket( Packet::PacketID( 0 ),
                                                   m_moduleCom.getNextRequestID(),
                                                   overviewMapID,
                                                   false,
                                                   idPairs ) );
      // create the packet container
      idTransReqPackets.
         push_back( new PacketContainer( idPacket.release(), 
                                         0, 
                                         0, 
                                         MODULE_TYPE_MAP ) );
      lowLevelIDPairs.push_back( idPairs );

      mc2dbg4 << "[RTIPC] lowLevelIDPairs size: " << lowLevelIDPairs.size() << endl;
     
   }
}
Пример #29
0
/**
 *
 * Disconnects any objects identified by receiver and/or id
 *
 * @param receiver The receiver to disconnect
 * @param id The id of the queue to disconnect
 */
void SmartObject::disconnectQueue(const SmartObject *receiver, int id)
{
    // Lock mutex
    mutex.lock();

    if (id != 0) {

        if (receiver == nullptr) {

            // A function wasn't passed, so lets disconnect everything related
            // to this id
            connectedObjects.erase(connectedObjects.find(id));
        } else {
            auto objects = connectedObjects;

            // Copy objects so we don't explode things when we delete while
            // iterating
            auto its = objects.equal_range(id);

            for (auto it = its.first; it != its.second; ++it) {

                if (it->second == receiver) {

                    // Disconnect this
                    connectedObjects.erase(it);
                }
            }
        }
    } else if (receiver != nullptr) {

        // Copy objects so we don't explode things when we delete while
        // iterating
        auto objects = connectedObjects;

        for (auto it = objects.begin(); it != objects.end(); ++it) {

            if (it->second == receiver) {

                // Disconnect this
                connectedObjects.erase(it);
            }
        }
    } else {

        // Disconnect all piipes
        connectedObjects.clear();
    }

    // Unlock mutex
    mutex.unlock();
}
Пример #30
0
void sorted_array_search(){
    cout<<endl<<"sorted_array_search :"<<endl;
    int ia[] = {0, 1,  3, 4,4,4,4, 5, 8, 11 };
    vector<int> iv(ia,ia+sizeof(ia)/sizeof(int));	vector<int>::iterator itr;
    cout<<iv<<endl;
    itr = lower_bound(iv.begin(),iv.end(), 8);
    cout<<"lower_bound: "<<*itr<<endl;
    itr = upper_bound(iv.begin(),iv.end(), 8);
    cout<<"upper_bound: "<<*itr<<endl;
    cout<<"binary_search: "<<binary_search(iv.begin(),iv.end(), 6)<<endl;
    vector<int>::iterator lowerb, upperb;
    pair<vector<int>::iterator, vector<int>::iterator> rst = equal_range(iv.begin(),iv.end(),4);
    cout<<"equal_range: "<<*rst.first<<" "<<*rst.second<<endl;
}