<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Pattern Matching auf polymorphen Baum - Wie?]]></title><description><![CDATA[<p>Hallo Leute,</p>
<p>Ich habe schon mehrmals Pattern Matching auf polymorphen Baeumen gebraucht, z.B. im Parserbau. Meine bisherigen Loesungen gefallen mir nicht:</p>
<ul>
<li>dynamic_cast auf jedem Element und allen Child-Elementen</li>
<li>Eine virtuelle .is(type) Funktion + Type Enum</li>
</ul>
<p>Beides ist weder sonderlich lesbar noch wartbar.</p>
<p>Ich suche daher nach einer Loesung, das Konzept des Pattern Matchings irgendwie generisch zu kapseln. Hat vielleicht schon mal jemand von euch dasselbe Problem gehabt und einen Ansatz fuer mich?</p>
<p>Gruessle,<br />
Der Kellerautomat</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/318591/pattern-matching-auf-polymorphen-baum-wie</link><generator>RSS for Node</generator><lastBuildDate>Mon, 27 Jul 2026 05:37:12 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/318591.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 18 Jul 2013 21:00:42 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Pattern Matching auf polymorphen Baum - Wie? on Thu, 18 Jul 2013 21:00:54 GMT]]></title><description><![CDATA[<p>Hallo Leute,</p>
<p>Ich habe schon mehrmals Pattern Matching auf polymorphen Baeumen gebraucht, z.B. im Parserbau. Meine bisherigen Loesungen gefallen mir nicht:</p>
<ul>
<li>dynamic_cast auf jedem Element und allen Child-Elementen</li>
<li>Eine virtuelle .is(type) Funktion + Type Enum</li>
</ul>
<p>Beides ist weder sonderlich lesbar noch wartbar.</p>
<p>Ich suche daher nach einer Loesung, das Konzept des Pattern Matchings irgendwie generisch zu kapseln. Hat vielleicht schon mal jemand von euch dasselbe Problem gehabt und einen Ansatz fuer mich?</p>
<p>Gruessle,<br />
Der Kellerautomat</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2339749</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2339749</guid><dc:creator><![CDATA[Kellerautomat]]></dc:creator><pubDate>Thu, 18 Jul 2013 21:00:54 GMT</pubDate></item><item><title><![CDATA[Reply to Pattern Matching auf polymorphen Baum - Wie? on Thu, 18 Jul 2013 21:34:20 GMT]]></title><description><![CDATA[<p>Graphisomorphie ist NP-vollstaendig, wie es bei Baeumen ausschaut, weiss ich nicht recht wenn die Reihenfolge von Kindknoten unerheblich sein soll.</p>
<p>Ansonsten: tagged unions. Weiterhin gibt es die Moeglichkeit RTTI zu nutzen, bspw. typeid etc.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2339751</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2339751</guid><dc:creator><![CDATA[knivil]]></dc:creator><pubDate>Thu, 18 Jul 2013 21:34:20 GMT</pubDate></item><item><title><![CDATA[Reply to Pattern Matching auf polymorphen Baum - Wie? on Thu, 18 Jul 2013 22:24:53 GMT]]></title><description><![CDATA[<p>knivil schrieb:</p>
<blockquote>
<p>Graphisomorphie ist NP-vollstaendig</p>
</blockquote>
<p>Beweis?</p>
<blockquote>
<p>wie es bei Baeumen ausschaut, weiss ich nicht recht wenn die Reihenfolge von Kindknoten unerheblich sein soll.</p>
</blockquote>
<p>Lässt sich in linearer Zeit lösen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2339756</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2339756</guid><dc:creator><![CDATA[Michael E.]]></dc:creator><pubDate>Thu, 18 Jul 2013 22:24:53 GMT</pubDate></item><item><title><![CDATA[Reply to Pattern Matching auf polymorphen Baum - Wie? on Thu, 18 Jul 2013 23:13:47 GMT]]></title><description><![CDATA[<p>Angenommen es gibt ein struct Token von dem mehrere Klassen abgeleitet sind:<br />
Wie wärs mit</p>
<pre><code>bool Token::isSameTokenType(const Token *t){
    return typeid(*this) == typeid(*t);
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2339758</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2339758</guid><dc:creator><![CDATA[nwp3]]></dc:creator><pubDate>Thu, 18 Jul 2013 23:13:47 GMT</pubDate></item><item><title><![CDATA[Reply to Pattern Matching auf polymorphen Baum - Wie? on Fri, 19 Jul 2013 08:18:28 GMT]]></title><description><![CDATA[<p>Michael E. schrieb:</p>
<blockquote>
<p>knivil schrieb:</p>
<blockquote>
<p>Graphisomorphie ist NP-vollstaendig</p>
</blockquote>
<p>Beweis?</p>
</blockquote>
<blockquote>
<p>Subgraph isomorphism is a generalization of both the maximum clique problem and the problem of testing whether a graph contains a Hamiltonian cycle, and is therefore NP-complete</p>
</blockquote>
<blockquote>
<p>Lässt sich in linearer Zeit lösen.</p>
</blockquote>
<p>Lol Beweis? Lineare Zeit in Abhaengigkeit von was? Knoten, Kanten, Sternchen? ... Ich sag erstmal glaub ich nicht.</p>
<p>Beispiel:</p>
<pre><code>a = [1 2 3 4 5 6 7]
b = [3 1 5 6 7 2 4]
</code></pre>
<p>Nummern bezeichnen deine Knoten die an einem Wurzelknoten haengen, b ist dein Pattern. Frage: Ist Menge b in a enthalten.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2339790</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2339790</guid><dc:creator><![CDATA[knivil]]></dc:creator><pubDate>Fri, 19 Jul 2013 08:18:28 GMT</pubDate></item><item><title><![CDATA[Reply to Pattern Matching auf polymorphen Baum - Wie? on Fri, 19 Jul 2013 08:27:44 GMT]]></title><description><![CDATA[<p>knivil schrieb:</p>
<blockquote>
<p>Michael E. schrieb:</p>
<blockquote>
<p>knivil schrieb:</p>
<blockquote>
<p>Graphisomorphie ist NP-vollstaendig</p>
</blockquote>
<p>Beweis?</p>
</blockquote>
<blockquote>
<p>Subgraph isomorphism is a generalization of both the maximum clique problem and the problem of testing whether a graph contains a Hamiltonian cycle, and is therefore NP-complete</p>
</blockquote>
</blockquote>
<p>Nett, dass du die vorherige Bemerkung entfernt hast. Nicht so nett, dass du das Problem von Graphisomorphie zu Subgraphisomorphie geändert hast. Für Graphisomorphie ist es nämlich nicht bekannt, ob es NP-vollständig ist (und es ist IMHO auch ziemlich unwahrscheinlich).</p>
<blockquote>
<blockquote>
<p>Lässt sich in linearer Zeit lösen.</p>
</blockquote>
<p>Lol Beweis? Lineare Zeit in Abhaengigkeit von was? Knoten, Kanten, Sternchen? ... Ich sag erstmal glaub ich nicht.</p>
</blockquote>
<p>Na was wohl? Linear heißt bei Graphen linear in Knoten- und Kantenzahl. Da die bei Bäumen fast gleich sind, kannst du dir eins aussuchen.</p>
<p><a href="http://perso.ens-lyon.fr/eric.thierry/Graphes2010/marthe-bonamy.pdf" rel="nofollow">http://perso.ens-lyon.fr/eric.thierry/Graphes2010/marthe-bonamy.pdf</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2339795</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2339795</guid><dc:creator><![CDATA[Michael E.]]></dc:creator><pubDate>Fri, 19 Jul 2013 08:27:44 GMT</pubDate></item><item><title><![CDATA[Reply to Pattern Matching auf polymorphen Baum - Wie? on Fri, 19 Jul 2013 08:39:37 GMT]]></title><description><![CDATA[<blockquote>
<p>Graphisomorphie zu Subgraphisomorphie</p>
</blockquote>
<p>Und du hast den Kontext wohl vergessen ... Pattern matching.</p>
<blockquote>
<p>Na was wohl? Linear heißt bei Graphen linear in Knoten- und Kantenzahl. Da die bei Bäumen fast gleich sind, kannst du dir eins aussuchen.</p>
</blockquote>
<p>Das ist mir klar, aber ich wuerde das Pattern an sich auch mit einbeziehen, wie ich versucht habe im Beispiel darzulegen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2339799</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2339799</guid><dc:creator><![CDATA[knivil]]></dc:creator><pubDate>Fri, 19 Jul 2013 08:39:37 GMT</pubDate></item><item><title><![CDATA[Reply to Pattern Matching auf polymorphen Baum - Wie? on Fri, 19 Jul 2013 09:05:56 GMT]]></title><description><![CDATA[<p>knivil schrieb:</p>
<blockquote>
<blockquote>
<p>Graphisomorphie zu Subgraphisomorphie</p>
</blockquote>
<p>Und du hast den Kontext wohl vergessen ... Pattern matching.</p>
</blockquote>
<p>Nein, genauer gesagt hab ich mich noch nie mit Pattern Matching befasst und werde es auch jetzt nicht tun. Daher weiß ich auch nicht, ob wir hier nun Graph- oder Subgraphisomorphismus gebrauchen können. Ich bin lediglich auf deine Behauptung eingegangen, dass Graphisomorphie NP-vollständig sein soll. Wenn Graphisomorphie nicht das richtige Werkzeug für Pattern Matching ist, kannst du auch einfach zugeben, dass du ein &quot;Sub-&quot; vergessen hast.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2339805</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2339805</guid><dc:creator><![CDATA[Michael E.]]></dc:creator><pubDate>Fri, 19 Jul 2013 09:05:56 GMT</pubDate></item></channel></rss>