当前位置: 首页>>代码示例>>C++>>正文


C++ HashTable::clear方法代码示例

本文整理汇总了C++中HashTable::clear方法的典型用法代码示例。如果您正苦于以下问题:C++ HashTable::clear方法的具体用法?C++ HashTable::clear怎么用?C++ HashTable::clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在HashTable的用法示例。


在下文中一共展示了HashTable::clear方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: canSubmit

bool canSubmit ( unsigned long h , long now , long maxAddUrlsPerIpDomPerDay ) {
	// . sometimes no limit
	// . 0 means no limit because if they don't want any submission they
	//   can just turn off add url and we want to avoid excess 
	//   troubleshooting for why a url can't be added
	if ( maxAddUrlsPerIpDomPerDay <= 0 ) return true;
	// init the table
	if ( ! s_init ) {
		s_htable.set ( 50000 );
		s_init = true;
	}
	// clean out table every 24 hours
	if ( now - s_lastTime > 24*60*60 ) {
		s_lastTime = now;
		s_htable.clear();
	}
	// . if table almost full clean out ALL slots
	// . TODO: just clean out oldest slots
	if ( s_htable.getNumSlotsUsed() > 47000 ) s_htable.clear ();
	// . how many times has this IP domain submitted?
	// . allow 10 times per day
	long n = s_htable.getValue ( h );
	// if over 24hr limit then bail
	if ( n >= maxAddUrlsPerIpDomPerDay ) return false;
	// otherwise, inc it
	n++;
	// add to table, will replace old values
	s_htable.addKey ( h , n );
	return true;
}
开发者ID:RevBooyah,项目名称:open-source-search-engine,代码行数:30,代码来源:PageAddUrl.cpp

示例2: collisionTest

void collisionTest() {
    printf("test collision add/remove\n");
    
    HashTable<int,collisionHash,intEqual> collisiontable;
    for(int i=0;i<100;i++) {
	collisiontable.add(i);
    }
    for(int i=0;i<100;i+=2) {
	collisiontable.remove(i);
	size_t count = 0;
	for (HashTable<int,collisionHash,intEqual>::iterator i = collisiontable.begin();
	     i != collisiontable.end();i++) {
	    count++;
	}
	INVARIANT(count == collisiontable.size(),
		  boost::format("?! %d %d") % count % collisiontable.size());
    }

    // multiple adds of the same key are *supposed* to add multiple times.
    collisiontable.clear();
    SINVARIANT(collisiontable.size() == 0);
    for(int i=0;i<100;i++) {
	collisiontable.add(i);
	collisiontable.add(i);
    }
    SINVARIANT(collisiontable.size() == 200);

    // remove the keys (each twice)
    for(int i=0;i<100;i++) {
	collisiontable.remove(i, true);
	collisiontable.remove(i, true);
    }
    SINVARIANT(collisiontable.size() == 0);

    // an efficient way to do add/replace
    collisiontable.clear();
    SINVARIANT(collisiontable.size() == 0);
    for(int i=0;i<100;i++) {
	bool replaced;
	collisiontable.addOrReplace(i, replaced);
	SINVARIANT(replaced == false);
	collisiontable.addOrReplace(i, replaced);
	SINVARIANT(replaced == true);
    }
    SINVARIANT(collisiontable.size() == 100);

    // remove, add, remove the keys
    for(int i=0;i<100;i++) {
	collisiontable.remove(i, true);
	collisiontable.add(i);
	collisiontable.remove(i);
    }
    SINVARIANT(collisiontable.size() == 0);
}
开发者ID:dataseries,项目名称:Lintel,代码行数:54,代码来源:hashtable.cpp

示例3: dumpEngineDocs

static bool dumpEngineDocs( const char *outputFile )
{
   // Create the output stream.
   FileStream stream;
   if ( !stream.open( outputFile, Torque::FS::File::Write ) )
   {
      Con::errorf( "dumpEngineDocs - Failed to open output file." );
      return false;
   }

   // First dump all global ConsoleDoc fragments.
   
   for( ConsoleDocFragment* fragment = ConsoleDocFragment::smFirst; fragment != NULL; fragment = fragment->mNext )
      if( !fragment->mClass )
         dumpFragment( stream, fragment );
   
   // Clear the doc groups before continuing,
   smDocGroups.clear();
   
   // Dump enumeration types.
   dumpEnums( stream );
   
   // Dump all global variables.
   dumpVariables( stream );

   // Now dump the global functions.
   Namespace *g = Namespace::find( NULL );
   while( g ) 
   {
      dumpNamespaceEntries( stream, g );
      
      // Dump callbacks.
      dumpGroupStart( stream, "Callbacks" );
      dumpNamespaceEntries( stream, g, true );
      dumpGroupEnd( stream );

      g = g->mParent;
   }

   // Now dump all the classes.
   dumpClasses( stream );

   // Dump pre-declarations for any groups we encountered
   // so that we don't have to explicitly define them.
   HashTable<String,U32>::Iterator iter = smDocGroups.begin();
   for ( ; iter != smDocGroups.end(); iter++ )
      stream.writeText( String::ToString( "/*! @addtogroup %s */\r\n\r\n", iter->key.c_str() ) );

   return true;
}
开发者ID:Adhdcrazzy,项目名称:Torque3D,代码行数:50,代码来源:engineDoc.cpp

示例4: update

void update()
{
  cell temp = { 1 };
  newGrid.clear();
  for (temp.row = MINROW; temp.row <= MAXROW; temp.row++)
    for (temp.column = MINCOLUMN; temp.column <= MAXCOLUMN; temp.column++)
      switch (neighborCount(temp.row, temp.column))
    {
      case 2:
        if (grid.retrieve(temp)) newGrid.insert(temp);
        break;
      case 3:
        newGrid.insert(temp);
        break;
    }
    grid = newGrid;
};
开发者ID:Jthompson715,项目名称:github.io,代码行数:17,代码来源:Thompson_Jeremy_Lab11b_GameOfLife.cpp

示例5: clear

 PosibErr<void> clear() {lookup_.clear(); buffer_.reset(); return no_err;}
开发者ID:Distrotech,项目名称:aspell,代码行数:1,代码来源:string_map.hpp


注:本文中的HashTable::clear方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。