-
Path: news-archive.icm.edu.pl!news.icm.edu.pl!newsfeed2.atman.pl!newsfeed.atman.pl!.P
OSTED!not-for-mail
From: Borneq <b...@a...hidden.pl>
Newsgroups: pl.comp.programming
Subject: Re: Jak usunąć najlepiej element z drzewa ?
Date: Fri, 16 Mar 2018 00:07:31 +0100
Organization: ATMAN - ATM S.A.
Lines: 33
Message-ID: <p8eubi$mal$1@node1.news.atman.pl>
References: <p8cgcv$bd7$1@node1.news.atman.pl> <p8d69b$p3b$1@node2.news.atman.pl>
<p8dia4$4c4$1@node2.news.atman.pl> <p8dlhd$eah$1@node1.news.atman.pl>
<p8drp1$d3l$1@node2.news.atman.pl> <p8ds7o$l09$1@node1.news.atman.pl>
<p8dtuu$f4c$1@node2.news.atman.pl>
<9...@g...com>
<p8ee5g$6h9$1@node1.news.atman.pl>
<9...@g...com>
<p8epa1$hic$1@node1.news.atman.pl>
<1...@g...com>
<p8et3h$la0$1@node1.news.atman.pl>
NNTP-Posting-Host: public-gprs350577.centertel.pl
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: node1.news.atman.pl 1521155250 22869 37.47.0.178 (15 Mar 2018 23:07:30 GMT)
X-Complaints-To: u...@a...pl
NNTP-Posting-Date: Thu, 15 Mar 2018 23:07:30 +0000 (UTC)
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101
Thunderbird/52.6.0
In-Reply-To: <p8et3h$la0$1@node1.news.atman.pl>
Content-Language: pl
Xref: news-archive.icm.edu.pl pl.comp.programming:212337
[ ukryj nagłówki ]Replace:
nie można najpierw usuwać a potem dodawać , bo w międzyczasie zmieniłoby
się drzewo. Trzeba sklonować, potem usunąć i wstawić.
void InsertOneChild(int index, shared_ptr<Node> node)
{
childs.insert(childs.begin() + index, node);
node->parent = this;
}
void ReplaceChild(int index, shared_ptr<Node> subtree)
{
shared_ptr<Node> clone = subtree->cloneTree();
deleteChild(index);
InsertOneChild(index, clone);
clone->setLevel(level + 1);
}
int main()
{
shared_ptr<Node>root,rootB;
root = make_shared<Node>("1");
root->AddTree(make_shared<Node>("2"));
root->AddTree(make_shared<Node>("3"));
root->at(0)->AddTree(make_shared<Node>("4"));
root->at(0)->AddTree(make_shared<Node>("5"));
root->at(1)->AddTree(make_shared<Node>("6"));
root->at(1)->AddTree(make_shared<Node>("7"));
root->print();
root->ReplaceChild(0,root);
root->print();
return 0;
}
Następne wpisy z tego wątku
- 16.03.18 14:26 M.M.
Najnowsze wątki z tej grupy
- Do czego nadaje się QDockWidget z bibl. Qt?
- Bibl. Qt jest sztucznie ograniczona - jest nieprzydatna do celów komercyjnych
- Co sciaga kretynow
- AEiC 2024 - Ada-Europe conference - Deadlines Approaching
- Jakie są dobre zasady programowania programów opartych na wtyczkach?
- sprawdzanie słów kluczowych dot. zła
- Re: W czym sie teraz pisze programy??
- Re: (PDF) Surgical Pathology of Non-neoplastic Gastrointestinal Diseases by Lizhi Zhang
- CfC 28th Ada-Europe Int. Conf. Reliable Software Technologies
- Młodzi programiści i tajna policja
- Ada 2022 Language Reference Manual to be Published by Springer
- Press Release - AEiC 2023, Ada-Europe Reliable Softw. Technol.
- Ada-Europe - AEiC 2023 early registration deadline approaching
- Ada-Europe Int.Conf. Reliable Software Technologies, AEiC 2023
- Ile cykli zajmuje mnożenie liczb 64-bitowych?
Najnowsze wątki
- 2024-05-18 Warszawa => Mid PHP Developer (Laravel) <=
- 2024-05-18 Warszawa => Software .Net Developer <=
- 2024-05-18 Warszawa => Mid/Senior QA Engineer <=
- 2024-05-18 Ulm => Solution Architect (sichere Kommunikation und IoT-Loesungen <=
- 2024-05-18 Katowice => Head of Virtualization Platform Management and Operating S
- 2024-05-18 Warszawa => SAP WM Consultant / Execution <=
- 2024-05-18 Wrocław => Consultant/Implementer Comarch ERP XL <=
- 2024-05-18 Gdańsk => Head of International Freight Forwarding Department <=
- 2024-05-18 Warszawa => Account Manager (Recruitment Services) <=
- 2024-05-18 Łódź => Salesperson - CRM Systems <=
- 2024-05-18 Łódź => Handlowiec - Systemy CRM <=
- 2024-05-17 ZŁOMNIK o pracy w TVN TURBO, nowych przepisach i współczesnej motoryzacji. Turbo Taryfa!
- 2024-05-17 Białystok => DevOps Engineer Conexa First (Contractor) <=
- 2024-05-17 Warszawa => Starszy inżynier oprogramowania (Rust) <=
- 2024-05-17 Zabrze => Junior HelpDesk <=