gravatar
alpar (Alpar Juttner)
alpar@cs.elte.hu
Merge
0 1 0
merge default
1 file changed with 3 insertions and 1 deletions:
↑ Collapse diff ↑
Ignore white space 48 line context
... ...
@@ -284,49 +284,51 @@
284 284
    ///
285 285
    void clear() {
286 286
      Parent::clear();
287 287
    }
288 288

	
289 289
    ///Split a node.
290 290

	
291 291
    ///This function splits a node. First a new node is added to the digraph,
292 292
    ///then the source of each outgoing arc of \c n is moved to this new node.
293 293
    ///If \c connect is \c true (this is the default value), then a new arc
294 294
    ///from \c n to the newly created node is also added.
295 295
    ///\return The newly created node.
296 296
    ///
297 297
    ///\note The <tt>Arc</tt>s
298 298
    ///referencing a moved arc remain
299 299
    ///valid. However <tt>InArc</tt>'s and <tt>OutArc</tt>'s
300 300
    ///may be invalidated.
301 301
    ///\warning This functionality cannot be used together with the Snapshot
302 302
    ///feature.
303 303
    Node split(Node n, bool connect = true)
304 304
    {
305 305
      Node b = addNode();
306 306
      nodes[b._id].first_out=nodes[n._id].first_out;
307 307
      nodes[n._id].first_out=-1;
308
      for(int i=nodes[b._id].first_out;i!=-1;i++) arcs[i].source=b._id;
308
      for(int i=nodes[b._id].first_out; i!=-1; i=arcs[i].next_out) {
309
        arcs[i].source=b._id;
310
      }
309 311
      if(connect) addArc(n,b);
310 312
      return b;
311 313
    }
312 314

	
313 315
  public:
314 316

	
315 317
    class Snapshot;
316 318

	
317 319
  protected:
318 320

	
319 321
    void restoreSnapshot(const Snapshot &s)
320 322
    {
321 323
      while(s.arc_num<arcs.size()) {
322 324
        Arc arc = arcFromId(arcs.size()-1);
323 325
        Parent::notifier(Arc()).erase(arc);
324 326
        nodes[arcs.back().source].first_out=arcs.back().next_out;
325 327
        nodes[arcs.back().target].first_in=arcs.back().next_in;
326 328
        arcs.pop_back();
327 329
      }
328 330
      while(s.node_num<nodes.size()) {
329 331
        Node node = nodeFromId(nodes.size()-1);
330 332
        Parent::notifier(Node()).erase(node);
331 333
        nodes.pop_back();
332 334
      }
0 comments (0 inline)