Exemplo n.º 1
0
Arquivo: main.cpp Projeto: CCJY/coliru
int main()
{
    std::multimap<std::string, std::string> m{{"Hello", "World"}, {"Bye", "World"}, {"Foo", "Bar"}};
    std::vector<decltype(m)::value_type> vec;
    
    std::copy_if(m.begin(), m.end(), std::back_inserter(vec),
        [](decltype(m)::value_type const& kv) {
            return std::any_of(kv.first.begin(), kv.first.end(), 
                               [](std::string::value_type c) { return c == 'e'; });
        });
    
    for(auto const& v : vec) {
        std::cout << v.first << ": " << v.second << std::endl;
    }
}
Exemplo n.º 2
0
	void Manager::unloadUnused()
	{
		std::vector< decltype( resources )::iterator > unload;
		for ( auto it = resources.begin(); it != resources.end(); ++it )
		{
			if ( it->second->refs == 0 )
			{
				unload.push_back( it );
			}
		}
		
		for ( auto it = unload.begin(); it != unload.end(); ++it )
		{
			resources.erase( * it );
		}
	}
Exemplo n.º 3
0
	static never_inline void initialize_tls()
	{
		// allocate if not initialized
		if (!g_tls_net_data)
		{
			g_tls_net_data.set(vm::alloc(sizeof(decltype(g_tls_net_data)::type), vm::main));
			
			// Initial values
			g_tls_net_data->_errno = SYS_NET_EBUSY;

			thread_ctrl::atexit([addr = g_tls_net_data.addr()]
			{
				vm::dealloc_verbose_nothrow(addr, vm::main);
			});
		}
	}
Exemplo n.º 4
0
Dictionnary Dictionnary::FromSerialized(std::istream& in) {
    Dictionnary dict;
    size_t nb;
    in >> nb;

    std::string w;
    size_t id;
    dict.stats_.resize(nb);
    for (size_t i = 0; i < nb; ++i) {
        in >> w >> id;
        in >> dict.stats_[id];
        dict.dict_.insert(decltype (dict.dict_)::value_type(w, id));
    }

    return dict;
}
Exemplo n.º 5
0
void Reports::checkBreakActions(const Experiment &experiment,
                                const std::vector<Report::Event> &events) {
    auto available = std::unordered_set<std::int32_t>{};
    for (const auto &action : experiment.breakActions) {
        available.insert(action.ID);
    }

    for (const auto &event : events) {
        if (!event.exhibitID) {
            if (!utils::all_of(event.actions,
                               std::bind(&decltype(available)::count, &available, _1))) {
                throw InvalidData{"incorrect break action ID"};
            }
        }
    }
}
Exemplo n.º 6
0
Torrent::Torrent(string path) :
	m_path(path)
{
	m_torrent_params.save_path = "./";
	if (gt::Core::isMagnetLink(path))
	{
		m_torrent_params.url = path;
	}
	else
	{
			//libtorrent::add_torrent_params.ti is an intrusive_ptr in 1.0 and a shared_ptr in svn.
			//Using decltype allows us to make it compatible with both versions while still properly using the constructor to avoid a compiler error on boost 1.55 when the = operator is used with a pointer.
			m_torrent_params.ti = decltype(m_torrent_params.ti)(new libtorrent::torrent_info(path)); 
	}

}
Exemplo n.º 7
0
const IrisValue & IrisModule::GetCurrentModuleConstance(const string& strConstanceName, bool& bResult)
{
	decltype(m_hsConstances)::iterator iVariable;
	m_iwlModuleConstanceWLLock.ReadLock();
	if ((iVariable = m_hsConstances.find(strConstanceName)) != m_hsConstances.end()) {
		auto& ivResult = iVariable->second;
		bResult = true;
		m_iwlModuleConstanceWLLock.ReadUnlock();
		return ivResult;
	}
	else {
		m_iwlModuleConstanceWLLock.ReadUnlock();
		bResult = false;
		return IrisDevUtil::Nil();
	}
}
Exemplo n.º 8
0
void Sz4BlockTestCase::weigthedSumTest2() {
	typedef sz4::value_time_pair<short, sz4::second_time_t> pair_type;
	std::vector<pair_type> v;
	sz4::concrete_block<short, unsigned> block(0u, &m_cache);
	sz4::weighted_sum<short, sz4::second_time_t> wsum;
	sz4::weighted_sum<short, sz4::second_time_t>::time_diff_type weight;

	v.push_back(sz4::make_value_time_pair<pair_type>((short)1, 1u));
	v.push_back(sz4::make_value_time_pair<pair_type>(std::numeric_limits<short>::min(), 2u));
	v.push_back(sz4::make_value_time_pair<pair_type>((short)1, 3u));
	block.set_data(v);

	block.get_weighted_sum(0u, 3u, wsum);
	CPPUNIT_ASSERT_EQUAL(decltype(wsum)::sum_type(2), wsum.sum(weight));
	CPPUNIT_ASSERT_EQUAL(2l, weight);
}
Exemplo n.º 9
0
/// Erase from a list of wcstring values at specified indexes.
static void erase_values(wcstring_list_t &list, const std::vector<long> &indexes) {
    // Make a set of indexes.
    // This both sorts them into ascending order and removes duplicates.
    const std::set<long> indexes_set(indexes.begin(), indexes.end());

    // Now walk the set backwards, so we encounter larger indexes first, and remove elements at the
    // given (1-based) indexes.
    decltype(indexes_set)::const_reverse_iterator iter;
    for (iter = indexes_set.rbegin(); iter != indexes_set.rend(); ++iter) {
        long val = *iter;
        if (val > 0 && (size_t)val <= list.size()) {
            // One-based indexing!
            list.erase(list.begin() + val - 1);
        }
    }
}
Exemplo n.º 10
0
silly_renderer::silly_renderer()
  : m_renderWindowInteractor(decltype(m_renderWindowInteractor)::New())
{
  // Create a sphere
  vtkSmartPointer<vtkSphereSource> sphereSource =
    vtkSmartPointer<vtkSphereSource>::New();
  sphereSource->Update();

  vtkSmartPointer<vtkProgrammableFilter> programmableFilter =
    vtkSmartPointer<vtkProgrammableFilter>::New();
  programmableFilter->SetInputConnection(sphereSource->GetOutputPort());
  programmableFilter->SetExecuteMethod(AdjustPoints, programmableFilter);

  // Create a mapper and actor
  vtkSmartPointer<vtkPolyDataMapper> mapper =
    vtkSmartPointer<vtkPolyDataMapper>::New();
  mapper->SetInputConnection(programmableFilter->GetOutputPort());
  vtkSmartPointer<vtkActor> actor =
    vtkSmartPointer<vtkActor>::New();
  actor->SetMapper(mapper);

  // Create a renderer, render window, and interactor
  vtkSmartPointer<vtkRenderer> renderer =
    vtkSmartPointer<vtkRenderer>::New();
  vtkSmartPointer<vtkRenderWindow> renderWindow =
    vtkSmartPointer<vtkRenderWindow>::New();
  renderWindow->AddRenderer(renderer);

  m_renderWindowInteractor->SetRenderWindow(renderWindow);

  // Initialize must be called prior to creating timer events.
  m_renderWindowInteractor->Initialize();
  m_renderWindowInteractor->CreateRepeatingTimer(500);

  vtkSmartPointer<CommandSubclass> timerCallback =
    vtkSmartPointer<CommandSubclass>::New();
  timerCallback->ProgrammableFilter = programmableFilter;

  m_renderWindowInteractor->AddObserver ( vtkCommand::TimerEvent, timerCallback );

  // Add the actor to the scene
  renderer->AddActor(actor);
  renderer->SetBackground(1,1,1); // Background color white

  // Render
  renderWindow->Render();
}
Exemplo n.º 11
0
void setupSysEnd() {
    std::vector<Box*> builtin_module_names;
    for (int i = 0; PyImport_Inittab[i].name != NULL; i++)
        builtin_module_names.push_back(boxString(PyImport_Inittab[i].name));

    std::sort<decltype(builtin_module_names)::iterator, PyLt>(builtin_module_names.begin(), builtin_module_names.end(),
                                                              PyLt());

    sys_module->giveAttr("builtin_module_names",
                         BoxedTuple::create(builtin_module_names.size(), &builtin_module_names[0]));

    for (Box* b : builtin_module_names)
        Py_DECREF(b);

#ifndef NDEBUG
    for (const auto& p : *sys_modules_dict) {
        assert(PyString_Check(p.first));

        bool found = false;
        for (int i = 0; PyImport_Inittab[i].name != NULL; i++) {
            if (((BoxedString*)p.first)->s() == PyImport_Inittab[i].name) {
                found = true;
            }
        }
        if (!found)
            assert(0 && "found a module which is inside sys.modules but not listed inside PyImport_Inittab!");
    }
#endif

    /* version_info */
    if (VersionInfoType.tp_name == 0)
        PyStructSequence_InitType((PyTypeObject*)&VersionInfoType, &version_info_desc);
    /* prevent user from creating new instances */
    VersionInfoType.tp_init = NULL;
    VersionInfoType.tp_new = NULL;

    SET_SYS_FROM_STRING("version_info", make_version_info());

    /* float_info */
    if (FloatInfoType.tp_name == 0)
        PyStructSequence_InitType((PyTypeObject*)&FloatInfoType, &float_info_desc);
    /* prevent user from creating new instances */
    FloatInfoType.tp_init = NULL;
    FloatInfoType.tp_new = NULL;

    SET_SYS_FROM_STRING("float_info", PyFloat_GetInfo());
}
Exemplo n.º 12
0
static tuple<
        unique_ptr<AnimObj::Geom::nds_vt>,
        unique_ptr<AnimObj::Geom::NormalData::NsV>,
        unique_ptr<AnimObj::Geom::nds_vt>> extract(AnimObj::Geom::NormalData::NsV const& ons)
{
    std::vector<std::array<float, 3>> nrmf;
    Alembic::AbcGeom::N3fArraySample::value_vector::size_type const nsz = ons.size();
    nrmf.reserve(nsz);
    for (size_t k = 0; k < nsz; ++k)
    {
        Alembic::AbcGeom::N3fArraySample::value_type const& v = ons[k];
        decltype(nrmf)::value_type a = {v[0], v[1], v[2]};
        nrmf.emplace_back(a);
    }
    decltype(nrmf) nrms(nrmf);
    std::sort(nrms.begin(), nrms.end());
    std::size_t const d = std::distance(nrms.begin(), std::unique(nrms.begin(), nrms.end()));
    Alembic::AbcGeom::N3fArraySample::value_vector nsv(d);
    std::vector<std::pair<decltype(nrmf)::value_type, int>> nrmN;
    for (size_t m = 0; m < d; ++m)
    {
        decltype(nrms)::value_type const& n = nrms[m];
        nrmN.emplace_back(n, m);
        nsv[m] = {n[0], n[1], n[2]};
    }
    Alembic::AbcGeom::UInt32ArraySample::value_vector ndxv(nsz);
    Alembic::AbcGeom::UInt32ArraySample::value_vector ndrxv(d);
    decltype(nrmN)::const_iterator const& nrmNB = nrmN.cbegin();
    decltype(nrmN)::const_iterator const& nrmNE = nrmN.cend();
    for (size_t m = 0; m < nsz; ++m)
    {
        decltype(nrmN)::const_iterator const& found = std::lower_bound(
                nrmNB, nrmNE, nrmf[m],
                [](decltype(nrmN)::value_type const& a, decltype(nrmf)::value_type const& b)
                { return a.first < b; } );
        if (nrmNE == found)
        {
            continue;
        }
        ndrxv[std::distance(nrmNB, found)] = m;
        ndxv[m] = found->second;
    }
    return std::make_tuple(
            std::make_unique<AnimObj::Geom::nds_vt>(ndxv),
            std::make_unique<AnimObj::Geom::NormalData::NsV>(nsv),
            std::make_unique<AnimObj::Geom::nds_vt>(ndrxv));
}
Exemplo n.º 13
0
Arquivo: main.cpp Projeto: CCJY/coliru
int main(int argc, const char* argv[])
{
    std::string s1 = "abcd<ht";
    std::string s2 = "ml>giuya";
    
    boost::iterator_range<std::string::iterator> ir1 = boost::make_iterator_range(s1);
    boost::iterator_range<std::string::iterator> ir2 = boost::make_iterator_range(s2);
    auto ir3 = boost::join(ir1,ir2);
    
    boost::regex e("<[^>]*>");
    boost::match_results<decltype(ir3)::iterator> what;
    
    boost::regex_search(ir3.begin(), ir3.end(), what, e, 
                        boost::match_default | boost::match_partial);
    std::cout << std::string(what[0].first, what[0].second) << std::endl;
    //std::cout << what[0].second << std::endl;
}
Exemplo n.º 14
0
void
PolycrystalUserObjectBase::execute()
{
  if (!_colors_assigned)
    precomputeGrainStructure();
  // No need to rerun the object if the mesh hasn't changed
  else if (!_fe_problem.hasInitialAdaptivity())
    return;

  /**
   * We need one map per grain when creating the initial condition to support overlapping features.
   * Luckily, this is a fairly sparse structure.
   */
  _entities_visited.resize(getNumGrains());

  /**
   * This loop is similar to the one found in the base class however, there are two key differences
   * between building up the initial condition and discovering features based on solution variables:
   *
   * 1) When building up the initial condition, we aren't inspecting the actual variable values so
   *    we don't need to loop over all of the coupled variables.
   * 2) We want to discover all features on a single pass since there may be thousands of features
   *    in a simulation. However, we can only actively flood a single feature at a time. To make
   *    sure that we pick up all features that might start on a given entity, we'll keep retrying
   *    the flood routine on the same entity as long as new discoveries are being made. We know
   *    this information from the return value of flood.
   */
  for (const auto & current_elem : _mesh.getMesh().active_local_element_ptr_range())
  {
    // Loop over elements or nodes
    if (_is_elemental)
      while (flood(current_elem, invalid_size_t, nullptr))
        ;
    else
    {
      auto n_nodes = current_elem->n_vertices();
      for (auto i = decltype(n_nodes)(0); i < n_nodes; ++i)
      {
        const Node * current_node = current_elem->get_node(i);

        while (flood(current_node, invalid_size_t, nullptr))
          ;
      }
    }
  }
}
Exemplo n.º 15
0
template<class T> auto fooT(T t) {
  auto L = [](auto a)  { 
    auto M = [](char b)  {
      auto N = [](auto c)  {
        int x = 0;
        x = sizeof(a);        
        x = sizeof(b);
        x = sizeof(c);
      };  
      N('a');
      N(decltype(a){});
    };    
  };
  L(t);
  L(3.14);
  return 0;
}
Exemplo n.º 16
0
 auto test() {
   auto L = [](auto a) {
     print("a = ", a, "\n");
     foo(a);
     return [](decltype(a) b) {
       foo(b);
       foo(sizeof(a) + sizeof(b));
       return [](auto ... c) ->decltype(b) {
         print("c = ", c ..., "\n");
         foo(decltype(b){});
         foo(sizeof(decltype(a)*) + sizeof(decltype(b)*));
         return 42;
       };
     };
   };
   return L;
 }
Exemplo n.º 17
0
int main() {
  Solution sol;
  string serialized_tree("5 4 11 7 # # 2 # # # 8 13 # # 4 5 # # 1 4 # # #");
  TreeNode *root = deserialize_tree(serialized_tree);
  preorder_cout(root);
  int sum = 22;
  // auto result = sol.pathSum(root, sum);
  // auto result = sol.pathSum(NULL, 0);
  // auto result = sol.pathSum(root->right->left, 13);
  auto result = sol.pathSum(root->right->right, 9);
  for (auto row: result) {
    copy(row.begin(), row.end(), 
      ostream_iterator<decltype(row)::value_type>(cout, " "));
    cout << '\n';
  }
  return 0;
}
Exemplo n.º 18
0
CMT_NOINLINE expression_pointer<T> window(size_t size, window_type type, identity<T> win_param,
                                          window_symmetry symmetry = window_symmetry::symmetric,
                                          ctype_t<T>               = ctype_t<T>())
{
    return cswitch(
        cvals_t<window_type, window_type::rectangular, window_type::triangular, window_type::bartlett,
                window_type::cosine, window_type::hann, window_type::bartlett_hann, window_type::hamming,
                window_type::bohman, window_type::blackman, window_type::blackman_harris, window_type::kaiser,
                window_type::flattop, window_type::gaussian, window_type::lanczos>(),
        type,
        [size, win_param, symmetry](auto win) {
            constexpr window_type window = val_of(decltype(win)());
            return to_pointer(
                typename internal::window_by_type<window>::template type<T>(size, win_param, symmetry));
        },
        fn_generic::returns<expression_pointer<T>>());
}
Exemplo n.º 19
0
	static py::object seqVectorToPy(const IteratorRange& range, ItemGetter itemGetter, bool zipped){
		if(!zipped){
			size_t num=decltype(itemGetter(*(range.begin())))::RowsAtCompileTime;
			vector<py::list> ret(num);
			for(const auto& p: range){
				auto item=itemGetter(p);
				for(int i=0; i<item.size(); i++) ret[i].append(item[i]);
			}
			py::list l;
			for(size_t i=0; i<ret.size(); i++) l.append(ret[i]);
			return py::tuple(l);
		} else {
			py::list ret;
			for(const auto& p: range){ ret.append(itemGetter(p)); }
			return ret;
		}
	}
Exemplo n.º 20
0
PropertyDataType ExponentialProperty::d2Value(
    VariableArray const& variable_array,
    Variable const pv1,
    Variable const pv2) const
{
    return _exponent_data.type == pv1 && _exponent_data.type == pv2
               ? boost::get<double>(_value) *
                     boost::math::pow<2>(
                         boost::get<double>(_exponent_data.factor)) *
                     std::exp(
                         -boost::get<double>(_exponent_data.factor) *
                         (boost::get<double>(variable_array[static_cast<int>(
                              _exponent_data.type)]) -
                          boost::get<double>(
                              _exponent_data.reference_condition)))
               : decltype(_value){};
}
Exemplo n.º 21
0
 constexpr auto operator()(Def) const
 {
   constexpr auto children = hana::second(Def{});
   constexpr auto single_provider = hana::transform(hana::find(children, tag::Provider),
       hana::partial(mpdef::make_tree_node, tag::Provider));
   constexpr auto providers = hana::find(children, tag::Providers);
   static_assert(hana::value(
     ((single_provider == hana::nothing) || (providers == hana::nothing))
     && hana::not_(single_provider == hana::nothing && providers == hana::nothing)
   ), "A definition of a Provider or Providers is required.");
   return decltype(
     helper(providers.value_or(
         hana::maybe(mpdef::make_list(), mpdef::make_list, single_provider)
       )
     )
   ){};
 }
Exemplo n.º 22
0
File::Buffer File::read(const std::string& fileName)
{
	std::ifstream file(fileName.c_str(),
	                   std::ios::in | std::ios::binary | std::ios::ate);

	if (!file.is_open())
		throw std::runtime_error("Unable to open file: " + fileName);

	Buffer buf;
	buf.fileName = fileName;
	buf.data = decltype(Buffer::data)(file.tellg());

	file.seekg(0, std::ios::beg);
	file.read(&buf.data[0], buf.data.size());

	return buf;
}
Exemplo n.º 23
0
 static int main(CommandLine const &commandLine) {
     for (auto && arg : commandLine.argument) {
         if (arg == "-help" || arg == "-h" || arg == "-?") {
             usage(commandLine, false);
         }
     }
     auto outPath = std::string();
     auto source = std::string();
     auto verb = decltype(&reduce)(nullptr);
     for (auto && arg : commandLine.argument) {
         if (arg.substr(0, 5) == "-out=") {
             outPath = arg.substr(5);
             continue;
         }
         if (verb == nullptr) {
             if (arg == "map")
                 verb = &map;
             else if (arg == "reduce")
                 verb = &reduce;
             else
                 usage(commandLine, true);
             continue;
         }
         if (source.empty()) {
             source = arg;
             continue;
         }
         usage(commandLine, true);
     }
     
     if (source.empty())
         usage(commandLine, true);
     
     FILE *ofs = nullptr;
     if (!outPath.empty()) {
         ofs = fopen(outPath.c_str(), "w");
         if (!ofs) {
             std::cerr << "failed to open output file: " << outPath << std::endl;
             exit(3);
         }
     }
     auto rslt = (*verb)(ofs ? ofs : stdout, source);
     if (ofs) fclose(ofs);
     return rslt;
 }
Exemplo n.º 24
0
void
RequestLane::parseHeader(const std::string &name, const std::string &value)
{
  if (name == ":method") {
    _method = value;
  } else if (name == ":path") {
    _path = value;
  } else if (name == ":scheme") {
    _scheme = value;
  } else if (name == ":authority") {
    _authority = value;
  } else if (name == "content-length") {
    _contentLength = parseDecimal<decltype(_contentLength)::value_type>(value);
    if (!_contentLength) {
      /* TODO: Malformed value; reset stream? */;
    }
  }
}
Exemplo n.º 25
0
void
FeatureFloodCount::visitElementalNeighbors(const Elem * elem, std::size_t current_index, FeatureData * feature, bool expand_halos_only)
{
  mooseAssert(elem, "Elem is NULL");

  std::vector<const Elem *> all_active_neighbors;

  // Loop over all neighbors (at the the same level as the current element)
  for (auto i = decltype(elem->n_neighbors())(0); i < elem->n_neighbors(); ++i)
  {
    const Elem * neighbor_ancestor = elem->neighbor(i);
    if (neighbor_ancestor)
      // Retrieve only the active neighbors for each side of this element, append them to the list of active neighbors
      neighbor_ancestor->active_family_tree_by_neighbor(all_active_neighbors, elem, false);
  }

  visitNeighborsHelper(elem, all_active_neighbors, current_index, feature, expand_halos_only);
}
Exemplo n.º 26
0
void Game::rotate(IView::quadrant quadrant, IView::turn direction){
    // get the sender == currentPlayer
    board.Rotate((Board::Quadrant)quadrant, (direction == IView::LEFT) ? Board::RotateDirection::Left : Board::RotateDirection::Right);
    if (currentPlayer < decltype(currentPlayer)(players.size()-1))
        currentPlayer++;
    else
        currentPlayer = 0;
    if (referee.UpdateWinState(board) != NoOne)
        emit message(players[currentPlayer]->GetName() + " Win!");

    /*string tmp = "\n";
    for (int i = 0; i<6;i++){
        for (int j = 0; j<6; j++)
            tmp += std::to_string(board[i][j]) + " ";
        tmp += "\n";
    }
    emit message(tmp);*/
}
Exemplo n.º 27
0
static int impl_unit_type_next(lua_State* L)
{
	const unit_type* base = *static_cast<const unit_type**>(luaL_testudata(L, 1, UnitTypeTable));
	auto unit_map = base ? base->variation_types() : unit_types.types();
	decltype(unit_map)::const_iterator it = unit_map.end();
	if(lua_isnoneornil(L, 2)) {
		if(base) {
			if(base->has_gender_variation(unit_race::MALE)) {
				lua_pushstring(L, "male");
				luaW_pushunittype(L, base->get_gender_unit_type(unit_race::MALE));
				return 2;
			} else if(base->has_gender_variation(unit_race::FEMALE)) {
				lua_pushstring(L, "female");
				luaW_pushunittype(L, base->get_gender_unit_type(unit_race::FEMALE));
				return 2;
			}
		}
		it = unit_map.begin();
	} else {
		const std::string id = luaL_checkstring(L, 2);
		if(base) {
			if(id == "male" && base->has_gender_variation(unit_race::FEMALE)) {
				lua_pushstring(L, "female");
				luaW_pushunittype(L, base->get_gender_unit_type(unit_race::FEMALE));
				return 2;
			} else if(id == "male" || id == "female") {
				it = unit_map.begin();
			}
		}
		if(it == unit_map.end()) {
			it = unit_map.find(id);
		}
		if(it == unit_map.end()) {
			return 0;
		}
		++it;
	}
	if (it == unit_map.end()) {
		return 0;
	}
	lua_pushlstring(L, it->first.c_str(), it->first.size());
	luaW_pushunittype(L, it->second);
	return 2;
}
Exemplo n.º 28
0
void
SphericalAverage::execute()
{
  // loop over quadrature points
  for (_qp = 0; _qp < _qrule->n_points(); ++_qp)
  {
    // compute target bin
    auto bin = computeDistance() / _deltaR;

    // add the volume contributed by the current quadrature point
    if (bin >= 0 && bin < static_cast<int>(_nbins))
    {
      for (auto j = decltype(_nvals)(0); j < _nvals; ++j)
        (*_average[j])[bin] += (*_values[j])[_qp];

      _counts[bin]++;
    }
  }
}
Exemplo n.º 29
0
void LightmapGenerator::InsertLightmap(int lightmapsize,
	int PolyIndex)
{
	bool bConstmap = true;
	for (int j = 0; j < lightmapsize*lightmapsize; j++)
	{
		if (lightmapdata[j] != lightmapdata[0])
		{
			bConstmap = false;
			ConstCount++;
			break;
		}
	}

	bool bNeedInsert = true;
	if (bConstmap)
	{
		lightmapsize = 2;

		auto it = ConstmapTable.find(lightmapdata[0]);
		if (it != ConstmapTable.end())
		{
			SourceLightmap[PolyIndex] = (*it).second;
			bNeedInsert = false;
		}
	}

	if (bNeedInsert)
	{
		int nLightmap = sourcelightmaplist.size();

		SourceLightmap[PolyIndex] = nLightmap;
		if (bConstmap)
			ConstmapTable.insert({ lightmapdata[0], nLightmap });

		sourcelightmaplist.emplace_back();
		auto& new_lightmap = sourcelightmaplist.back();
		new_lightmap.bLoaded = false;
		new_lightmap.nSize = lightmapsize;
		new_lightmap.data = decltype(new_lightmap.data){new u32[Square(lightmapsize)]};
		memcpy(new_lightmap.data.get(), lightmapdata.get(), Square(lightmapsize) * sizeof(u32));
	}
}
Exemplo n.º 30
0
Arquivo: udp.cpp Projeto: skypjack/uvw
TEST(UDP, Sock) {
    const std::string address = std::string{"127.0.0.1"};
    const unsigned int port = 4242;

    auto loop = uvw::Loop::getDefault();
    auto handle = loop->resource<uvw::UDPHandle>();

    handle->on<uvw::ErrorEvent>([](const auto &, auto &) { FAIL(); });

    handle->bind(address, port);
    handle->recv();

    uvw::Addr sock = handle->sock();
    ASSERT_EQ(sock.ip, address);
    ASSERT_EQ(sock.port, decltype(sock.port){port});

    handle->close();
    loop->run();
}