本文整理汇总了C++中std::list::splice方法的典型用法代码示例。如果您正苦于以下问题:C++ list::splice方法的具体用法?C++ list::splice怎么用?C++ list::splice使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::list
的用法示例。
在下文中一共展示了list::splice方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createBaseEdges
void ChowLiuTree::createBaseEdges(std::list<info>& edges, double infoThreshold) {
int nWords = imgDescriptors[0].cols;
#pragma omp parallel for schedule(dynamic, 500)
for(int word1 = 0; word1 < nWords; word1++) {
std::list<info> threadEdges;
info mutInfo;
for(int word2 = word1 + 1; word2 < nWords; word2++) {
mutInfo.word1 = (short)word1;
mutInfo.word2 = (short)word2;
mutInfo.score = (float)calcMutInfo(word1, word2);
if(mutInfo.score >= infoThreshold)
threadEdges.push_back(mutInfo);
}
#pragma omp critical
{
edges.splice(edges.end(), threadEdges);
}
// Status
if (nWords >= 10 && (word1+1)%(nWords/10) == 0)
std::cout << "." << std::flush;
}
edges.sort(sortInfoScores);
}
示例2: get
SDL_Surface* QuickSaveImageCache::get(std::string image_name) {
std::map<std::string, cache_iter_t>::iterator it = m_images.find(image_name);
if (it != m_images.end()) {
// found it: move to front of list
m_used.splice(m_used.begin(), m_used, it->second);
return it->second->second;
}
// didn't find: load image
FileSpecifier f;
f.SetToQuickSavesDir();
f.AddPart(image_name + ".sgaA");
WadImageDescriptor desc;
desc.file = f;
desc.checksum = 0;
desc.index = SAVE_GAME_METADATA_INDEX;
desc.tag = SAVE_IMG_TAG;
SDL_Surface *img = WadImageCache::instance()->get_image(desc, PREVIEW_WIDTH, PREVIEW_HEIGHT);
if (img) {
m_used.push_front(cache_pair_t(image_name, img));
m_images[image_name] = m_used.begin();
// enforce maximum cache size
if (m_used.size() > k_max_items) {
cache_iter_t lru = m_used.end();
--lru;
m_images.erase(lru->first);
SDL_FreeSurface(lru->second);
m_used.pop_back();
}
}
return img;
}
示例3: connectRects
void Rect::connectRects(std::list<std::pair<GEOMETRY_Object*, Rect> >& rects)
{
for(std::list<Rect>::iterator i = rects.begin(); i != rects.end(); ++i)
for(std::list<Rect>::iterator j = rects.begin(); j != rects.end(); )
if(i == j)
++j;
else if(i->isRectInside(*j))
j = rects.erase(j);
else if((j->getWidth() == 0) || (j->getHeight() == 0))
j = rects.erase(j);
else
{
std::list<Rect> t_list;
bool change = false;
t_list = i->connectRect(*j, change);
if(change)
{
rects.erase(i);
rects.erase(j);
rects.splice(rects.begin(), t_list);
j = rects.begin();
i = rects.begin();
} else ++j;
}
TODO
}
示例4: BuildDependencyList
void DataClassManager::BuildDependencyList(std::list<DataClass *> &dependencies, DataClassKind kind)
{
for(auto& i : m_map)
{
DataClass* dc = i.second;
if (dc->GetType()->GetKind() == kind)
{
std::list<DataClass*> current;
//see if something already depends on current dc
std::list<DataClass*>::iterator di;
for(di = dependencies.begin(); di != dependencies.end(); ++di)
{
if (*di == dc)
{
break;
}
}
if (di == dependencies.end())
{
current.push_back(dc); // new to the fray
}
else
{
//splice off current node and everything that depends on it
current.splice(current.begin(), dependencies, di, dependencies.end());
}
std::list<DataClass*> dependsOn;
dc->GetDirectDependencies(dependsOn);
//add depends on to the list if DNE
for(DataClass* d : dependsOn)
{
bool found = false;
for(DataClass* e : dependencies)
{
if (e == d)
{
found = true;
break;
}
}
if (!found)
{
dependencies.push_back(d);
}
}
//now splice in the current and list of everything that depends on it
dependencies.splice(dependencies.end(), current);
}
}
}
示例5: Read
// By design, succeed only if the entire request is in a single cached chunk
int ChunksCache::Read(void* pDest, PX_off_t offset, int length) {
for (auto it = m_entries.begin(); it != m_entries.end(); it++) {
CacheEntry* e = *it;
if (e && offset >= e->offset && (offset + length) <= (e->offset + e->coverage)) {
if (it != m_entries.begin())
m_entries.splice(m_entries.begin(), m_entries, it); // Move to top (MRU)
return CopyAvailable(e->data, e->offset, e->size, pDest, offset, length);
}
}
return -1;
}
示例6:
typename std::list<T, Allocator>::iterator
list_partition(std::list<T, Allocator>& list, Predicate predicate) {
auto first = list.begin();
auto last = list.end();
for (;;) {
for (; first != last && predicate(*first); ++first) {}
for (; first != last && !predicate(*std::prev(last)); --last) {}
if (first == last) {
return first;
}
auto next = std::next(first);
auto prev = std::prev(last);
list.splice(last, list, first);
list.splice(next, list, prev);
last = first;
first = next;
}
}
示例7: GetList
void DownloadsObserver::GetList(std::list<ObserverDownloadInfo>& lst)
{
wxMutexLocker lock(mutex);
std::list<IDownload*>::iterator it;
for (it = m_dl_list.begin(); it != m_dl_list.end(); ++it) {
ObserverDownloadInfo di = GetInfo((*it));
if (di.size > 0)
lst.push_back(di);
}
lst.splice(lst.begin(), m_finished_list);
}
示例8: bump
/** Bump a certain UIListener, such that it becomes the first in the line of all listeners.
* This may be required in situations where UIListeners need to (temporarily) ensure
* that they receive all input defined in their InputSet with absolute priority.
* Since it is not possible to return the InputSet to its original position, the only
* ways to reverse the change are:
* - Calling the same function for whatever UIListener receives conflicting input
* (this is difficult);
* - Only using this function for UIListeners that have limited effect and that, on
* specific input, will remove (nearly) all keys it defines in its InputSet, such
* that the input can again be received by its usual recipient (recommended).
*/
void bump(intf::UIListener * listener)
{
for(ListenerIterator it = listeners.begin(); it != listeners.end(); it++)
if(*it == listener)
{
// Move the listener to the front of the list.
listeners.splice(listeners.begin(), listeners, it);
return;
}
std::cout << " InputInterpreter::bump() :";
std::cout << " WARNING: Listener not found in keySets!"<<std::endl;
}
示例9: TryMove
TBool DviSsdpNotifierManager::TryMove(SsdpNotifierScheduler* aScheduler, std::list<Notifier*>& aFrom, std::list<Notifier*>& aTo)
{
std::list<Notifier*>::iterator it = aFrom.begin();
while (it != aFrom.end()) {
if ((*it)->Scheduler() == aScheduler) {
(*it)->SetInactive();
aTo.splice(aTo.end(), aFrom, it);
return true;
}
it++;
}
return false;
}
示例10: AllocChunk
void VDChunkedBuffer::AllocChunk() {
if (mFreeChunks.empty()) {
mFreeChunks.push_back(ChunkInfo());
ChunkInfo& ci = mFreeChunks.back();
ci.mpChunk = VDFile::AllocUnbuffer(mChunkSize);
if (!ci.mpChunk)
throw MyMemoryError();
ci.mChunkSize = mChunkSize;
}
mActiveChunks.splice(mActiveChunks.end(), mFreeChunks, mFreeChunks.begin());
}
示例11: GetChildren
static void GetChildren(std::list<std::string>& target,
ServerIndex& index,
const std::list<std::string>& source)
{
target.clear();
for (std::list<std::string>::const_iterator
it = source.begin(); it != source.end(); ++it)
{
std::list<std::string> tmp;
index.GetChildren(tmp, *it);
target.splice(target.end(), tmp);
}
}
示例12: setParent
void ofxWidget::setParent(std::shared_ptr<ofxWidget>& p_)
{
if (auto p = mParent.lock()) {
// TODO: handle already parented widgets
// how weird! this widget has a parent already.
// delete the widgets from the parent's child list
ofLogWarning() << "Widget already has parent!";
return;
}
// find ourselves in widget list
auto itMe = findIt(mThis, sAllWidgets.begin(), sAllWidgets.end());
// find parent in widget list
weak_ptr<ofxWidget> tmpParent = p_;
auto itParent = findIt(tmpParent, sAllWidgets.begin(), sAllWidgets.end());
/*
When an object gets a parent,
1. move it to the beginning of the parent's child range.
2. set its parent pointer
3. increase parent's child count by number of (own children + 1 ), recursively.
*/
if (itParent != sAllWidgets.end()) {
// move current element and its children to the front of the new parent's child range
if (auto parent = itParent->lock()) {
sAllWidgets.splice(
std::prev(itParent, parent->mNumChildren), // where to move elements to -> front of parent range
sAllWidgets, // where to take elements from
std::prev(itMe, mNumChildren), std::next(itMe)); // range of elements to move -> range of current element and its children
mParent = parent; // set current widget's new parent
// now increase the parents child count by (1+mNumChildren), recursively
parent->mNumChildren += (1 + mNumChildren);
while (parent = parent->mParent.lock()) {
// travel up parent hierarchy and increase child count for all ancestors
parent->mNumChildren += (1 + mNumChildren);
}
}
}
ofxWidget::bVisibleListDirty = true;
}
示例13: remove_internal
static void remove_internal( const std::function<bool( item & )> &filter, item &node, int &count,
std::list<item> &res )
{
for( auto it = node.contents.begin(); it != node.contents.end(); ) {
if( filter( *it ) ) {
res.splice( res.end(), node.contents, it++ );
if( --count == 0 ) {
return;
}
} else {
remove_internal( filter, *it, count, res );
++it;
}
}
}
示例14: append
void append(K const& key, VV&& value) {
std::unique_lock<std::mutex> lock(mutex);
if (map.find(key) != map.end()) {
map[key]->second = std::forward<VV>(value);
lst.splice(lst.begin(), lst, map[key]);
} else {
lst.emplace_front(key, std::forward<VV>(value));
}
map[key] = lst.begin();
if (lst.size() > max_size) {
map.erase(lst.back().first);
lst.pop_back();
}
}
示例15: uncross
//TODO: use path intersection stuff!
void uncross(std::list<Point> &loop){
std::list<Point>::iterator b0 = loop.begin(),a0,b1,a1;
if ( b0 == loop.end() ) return;
a0 = b0;
++b0;
if ( b0 == loop.end() ) return;
//now a0,b0 are 2 consecutive points.
while ( b0 != loop.end() ){
b1 = b0;
++b1;
if ( b1 != loop.end() ) {
a1 = b1;
++b1;
if ( b1 != loop.end() ) {
//now a0,b0,a1,b1 are 4 consecutive points.
Point c;
while ( b1 != loop.end() ){
if ( intersect(*a0,*b0,*a1,*b1,c) ){
if ( c != (*a0) && c != (*b0) ){
loop.insert(b1,c);
loop.insert(b0,c);
++a1;
std::list<Point> loop_piece;
loop_piece.insert(loop_piece.begin(), b0, a1 );
loop_piece.reverse();
loop.erase( b0, a1 );
loop.splice( a1, loop_piece );
b0 = a0;
++b0;
//a1 = b1; a1--;//useless
}else{
//TODO: handle degenerated crossings...
}
}else{
a1=b1;
++b1;
}
}
}
}
a0 = b0;
++b0;
}
return;//We should never reach this point.
}