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


C++ Arena类代码示例

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


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

示例1: defense

/*********************************************************************************
*Description - Defense fn 
*fn that send number of die and faces to Arena class and assesses the amount of 
*damage received 
*Parameters - Passes the amount of damage received to the the Armor fn, using 
polymorphism
*********************************************************************************/
void Reptile::defense() {

	int defend, damage, impact;

	battle3.setNumFaces(R_DEFEND_FACE);
	battle3.setNumDice(R_DEFEND_DIE);
	defend = battle3.Roll();	

	battle3.setDefendRoll(defend);
	damage = battle3.deathBlow();

		if(damage == 0)
		{
			cout << "No damage!!" << endl;
		}
			
			else if(damage > R_ARMOR)
			{	
				impact = damage - R_ARMOR;
				cout << "The Reptile People were injured! Because of armor, it only had an impact of: -"<< impact << endl; 
			}
			
				else if((damage > 0) && (damage <= R_ARMOR))
				{
					cout << "The Reptile People were hit, but were saved by their armor!!" << endl;
				}
	
				Character *chr = &rep;
				chr->armor(damage);
				chr->strength();

}
开发者ID:jtoth955,项目名称:CS-162,代码行数:39,代码来源:Reptile.cpp

示例2: cmd

Battle::Command Battle::Catapult::GetCommand(Arena & arena) const
{
    u32 shots = cat_shots;
    std::vector<u32> values(CAT_MISS + 1, 0);

    values[CAT_WALL1] = arena.GetCastleTargetValue(CAT_WALL1);
    values[CAT_WALL2] = arena.GetCastleTargetValue(CAT_WALL2);
    values[CAT_WALL3] = arena.GetCastleTargetValue(CAT_WALL3);
    values[CAT_WALL4] = arena.GetCastleTargetValue(CAT_WALL4);
    values[CAT_TOWER1] = arena.GetCastleTargetValue(CAT_TOWER1);
    values[CAT_TOWER2] = arena.GetCastleTargetValue(CAT_TOWER2);
    values[CAT_TOWER3] = arena.GetCastleTargetValue(CAT_TOWER3);
    values[CAT_BRIDGE] = arena.GetCastleTargetValue(CAT_BRIDGE);

    Command cmd(MSG_BATTLE_CATAPULT);
    cmd.GetStream() << shots;

    while(shots--)
    {
        int target = GetTarget(values);
        u32 damage = GetDamage(target, arena.GetCastleTargetValue(target));
        cmd.GetStream() << target << damage;
        values[target] -= damage;
    }

    return cmd;
}
开发者ID:mastermind-,项目名称:free-heroes,代码行数:27,代码来源:battle_catapult.cpp

示例3: main

int main()
{
  Comparator cmp;
  Arena arena;
  SkipList<Key, Comparator> list(cmp, &arena);
  const int N = 2000;
  std::set<Key> keys;
  for (int i = 0; i < N; i++)
  {
    list.Insert(i);
    keys.insert(i);
  }

  for (auto it = keys.begin(); it != keys.end(); ++it)
  {
    if (!list.Contains(*it))
    {
      cout<<*it<<"\t";
    }
  }

  size_t * p = (size_t*)(arena.AllocateAligned(sizeof(size_t)));
  *p = 100;
   cout<<*p<<endl;
   list.NewNodeTest(100, 12);
  return 0;
}
开发者ID:jiaweisong,项目名称:cpp_example,代码行数:27,代码来源:main.cpp

示例4: main

int main(int argc, char** argv) {
    srand(time(NULL));
    
    Arena<Fighter *> arena;
    arena.main();
    
    return 0;
}
开发者ID:sergot,项目名称:AncientFights,代码行数:8,代码来源:main.cpp

示例5: TEST

TEST(ArenaTest, AllocateStringPiece) {
    Arena arena;

    toft::StringPiece origin = "hello world";
    toft::StringPiece copy = arena.Allocate(origin);
    EXPECT_EQ(origin, copy);
    EXPECT_NE(origin.data(), copy.data());
    EXPECT_EQ(copy.data(), arena.current_block());
}
开发者ID:yangwei024,项目名称:bigflow,代码行数:9,代码来源:arena_test.cpp

示例6: get_MethodData

void ciMethodData::load_data() {
  MethodData* mdo = get_MethodData();
  if (mdo == NULL) {
    return;
  }

  // To do: don't copy the data if it is not "ripe" -- require a minimum #
  // of invocations.

  // Snapshot the data -- actually, take an approximate snapshot of
  // the data.  Any concurrently executing threads may be changing the
  // data as we copy it.
  Copy::disjoint_words((HeapWord*) mdo,
                       (HeapWord*) &_orig,
                       sizeof(_orig) / HeapWordSize);
  Arena* arena = CURRENT_ENV->arena();
  _data_size = mdo->data_size();
  _extra_data_size = mdo->extra_data_size();
  int total_size = _data_size + _extra_data_size;
  _data = (intptr_t *) arena->Amalloc(total_size);
  Copy::disjoint_words((HeapWord*) mdo->data_base(), (HeapWord*) _data, total_size / HeapWordSize);

  // Traverse the profile data, translating any oops into their
  // ci equivalents.
  ResourceMark rm;
  ciProfileData* ci_data = first_data();
  ProfileData* data = mdo->first_data();
  while (is_valid(ci_data)) {
    ci_data->translate_from(data);
    ci_data = next_data(ci_data);
    data = mdo->next_data(data);
  }
  if (mdo->parameters_type_data() != NULL) {
    _parameters = data_layout_at(mdo->parameters_type_data_di());
    ciParametersTypeData* parameters = new ciParametersTypeData(_parameters);
    parameters->translate_from(mdo->parameters_type_data());
  }

  load_extra_data();

  // Note:  Extra data are all BitData, and do not need translation.
  _current_mileage = MethodData::mileage_of(mdo->method());
  _invocation_counter = mdo->invocation_count();
  _backedge_counter = mdo->backedge_count();
  _state = mdo->is_mature()? mature_state: immature_state;

  _eflags = mdo->eflags();
  _arg_local = mdo->arg_local();
  _arg_stack = mdo->arg_stack();
  _arg_returned  = mdo->arg_returned();
#ifndef PRODUCT
  if (ReplayCompiles) {
    ciReplay::initialize(this);
  }
#endif
}
开发者ID:benbenolson,项目名称:hotspot_9_mc,代码行数:56,代码来源:ciMethodData.cpp

示例7: fetchNextFreeArena

Arena*
Chunk::allocateArena(JSRuntime* rt, Zone* zone, AllocKind thingKind, const AutoLockGC& lock)
{
    Arena* arena = info.numArenasFreeCommitted > 0
                   ? fetchNextFreeArena(rt)
                   : fetchNextDecommittedArena();
    arena->init(zone, thingKind);
    updateChunkListAfterAlloc(rt, lock);
    return arena;
}
开发者ID:alphan102,项目名称:gecko-dev,代码行数:10,代码来源:Allocator.cpp

示例8: traverse

        void traverse(const Arena& arena)                // Build up the name
        {
            if (ArenaPtr p = arena.parent())             // Has a parent arena?
            {
                traverse(*p);                            // ...traverse parent
                *this += '/';                            // ...add a delimiter
            }

            *this += arena.name();                       // Append arena name
        }
开发者ID:adam-dziedzic,项目名称:scidb,代码行数:10,代码来源:Arena.cpp

示例9: m_level

Spawner::Spawner(Arena& arena): m_level(1),
                                m_spawnDelay(sf::seconds(1.0f)),
                                m_arenaSize(arena.getSize()),
                                m_doorSize
                                (
                                    (arena.getSize().x / 2) - (arena.getSize().x / 6),
                                    (arena.getSize().x / 2) + (arena.getSize().x / 6)
                                ),
                                m_randLoc(0, 3)
{
}
开发者ID:Olysold,项目名称:ArenaShooter-SFML,代码行数:11,代码来源:Spawner.cpp

示例10: assert

// ------------------------------------------------------------------
// ciMethod::load_code
//
// Load the bytecodes and exception handler table for this method.
void ciMethod::load_code() {
  VM_ENTRY_MARK;
  assert(is_loaded(), "only loaded methods have code");

  methodOop me = get_methodOop();
  Arena* arena = CURRENT_THREAD_ENV->arena();

  // Load the bytecodes.
  _code = (address)arena->Amalloc(code_size());
  memcpy(_code, me->code_base(), code_size());

  // Revert any breakpoint bytecodes in ci's copy
  if (me->number_of_breakpoints() > 0) {
    BreakpointInfo* bp = instanceKlass::cast(me->method_holder())->breakpoints();
    for (; bp != NULL; bp = bp->next()) {
      if (bp->match(me)) {
        code_at_put(bp->bci(), bp->orig_bytecode());
      }
    }
  }

  // And load the exception table.
  typeArrayOop exc_table = me->exception_table();

  // Allocate one extra spot in our list of exceptions.  This
  // last entry will be used to represent the possibility that
  // an exception escapes the method.  See ciExceptionHandlerStream
  // for details.
  _exception_handlers =
    (ciExceptionHandler**)arena->Amalloc(sizeof(ciExceptionHandler*)
                                         * (_handler_count + 1));
  if (_handler_count > 0) {
    for (int i=0; i<_handler_count; i++) {
      int base = i*4;
      _exception_handlers[i] = new (arena) ciExceptionHandler(
                                holder(),
            /* start    */      exc_table->int_at(base),
            /* limit    */      exc_table->int_at(base+1),
            /* goto pc  */      exc_table->int_at(base+2),
            /* cp index */      exc_table->int_at(base+3));
    }
  }

  // Put an entry at the end of our list to represent the possibility
  // of exceptional exit.
  _exception_handlers[_handler_count] =
    new (arena) ciExceptionHandler(holder(), 0, code_size(), -1, 0);

  if (CIPrintMethodCodes) {
    print_codes();
  }
}
开发者ID:ismo1652,项目名称:jvmnotebook,代码行数:56,代码来源:ciMethod.cpp

示例11: attack

/*********************************************************************************
*Description - Attack fn Fn that passes number of die and die faces to Arena fn 
*Parameters - CONST for number of die and die faces
*********************************************************************************/
void Reptile::attack() {
	
	int attack;

	battle3.setNumFaces(R_ATTACK_FACE);
	battle3.setNumDice(R_ATTACK_DIE);
	attack = battle3.Roll();

	cout << "The Reptile People delivered a heavy blow to the opponent with a force of: " << attack << endl;
	
	battle3.setAttackRoll(attack);

}
开发者ID:jtoth955,项目名称:CS-162,代码行数:17,代码来源:Reptile.cpp

示例12: initVec

void ESFinder::initVec(vec &psi, const Arena &arena) {
  const std::size_t N = psi.size();

  VecTools::initRand(0);
  for (std::size_t i=0; i<N; i++) {
    const double pot = std::abs(arena.evaluatePotentialAtGridPoint(i));
    const double rnd = VecTools::getRandom(-pot, pot);
    psi[i] = rnd;
  }

  const double dx = arena.getStepSizeX();
  VecTools::normalize(psi, dx);
}
开发者ID:avitase,项目名称:rabi,代码行数:13,代码来源:esfinder.cpp

示例13: checkDescriptor

void Map::optimize(const fs::path& directory, const fs::path& target,
                   const Options& options) {
  const auto descriptor = internal::Descriptor::readFromDirectory(directory);
  checkDescriptor(descriptor, directory);
  fs::path prefix = directory / getPartitionPrefix(0);
  const Stats stats = internal::Partition::stats(prefix);
  Options new_options = options;
  new_options.error_if_exists = true;
  new_options.create_if_missing = true;
  if (options.block_size == 0) {
    new_options.block_size = stats.block_size;
  }
  if (options.num_partitions == 0) {
    new_options.num_partitions = descriptor.num_partitions;
  }
  Map new_map(target, new_options);

  for (int i = 0; i < descriptor.num_partitions; i++) {
    prefix = directory / getPartitionPrefix(i);
    if (options.verbose) {
      mt::log() << "Optimizing partition " << (i + 1) << " of "
                << descriptor.num_partitions << std::endl;
    }
    if (options.compare) {
      Arena arena;
      std::vector<Slice> values;
      internal::Partition::forEachEntry(
          prefix, [&new_map, &arena, &options, &values](const Slice& key,
                                                        Iterator* iter) {
            arena.deallocateAll();
            values.reserve(iter->available());
            values.clear();
            while (iter->hasNext()) {
              values.push_back(iter->next().makeCopy(&arena));
            }
            std::sort(values.begin(), values.end(), options.compare);
            for (const auto& value : values) {
              new_map.put(key, value);
            }
          });
    } else {
      internal::Partition::forEachEntry(
          prefix, [&new_map](const Slice& key, Iterator* iter) {
            while (iter->hasNext()) {
              new_map.put(key, iter->next());
            }
          });
    }
  }
}
开发者ID:mtrenkmann,项目名称:multimap,代码行数:50,代码来源:Map.cpp

示例14: attemptMove

  // Return false without changing anything if moving one step from (r,c)
  // in the indicated direction would hit a run off the edge of the arena.
  // Otherwise, update r and c to the position resulting from the move and
  // return true.
bool attemptMove(const Arena& a, int dir, int& r, int& c)
{
    int rnew = r;
    int cnew = c;
    switch (dir)
    {
      case NORTH:  if (r <= 1)        return false; else rnew--; break;
      case EAST:   if (c >= a.cols()) return false; else cnew++; break;
      case SOUTH:  if (r >= a.rows()) return false; else rnew++; break;
      case WEST:   if (c <= 1)        return false; else cnew--; break;
    }
    r = rnew;
    c = cnew;
    return true;
}
开发者ID:puneethv29,项目名称:CS32,代码行数:19,代码来源:utilities.cpp

示例15: dropBrain

string Player::dropBrain()
{
    if (m_arena->getCellStatus(m_row, m_col) == HAS_BRAIN)
        return "There's already a brain at this spot.";
    m_arena->setCellStatus(m_row, m_col, HAS_BRAIN);
    return "A brain has been dropped.";
}
开发者ID:wheredidjupark,项目名称:UCLA_CS32,代码行数:7,代码来源:zombies_base.cpp


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