gitweb on Svarog

projekti pod git sistemom za održavanje verzija -- projects under the git version control system
Stabla, dodati primeri algoritama nad stablima
authorIvan Pribela <ivanpribela@gmail.com>
Sun, 1 Nov 2015 14:57:03 +0000 (15:57 +0100)
committerIvan Pribela <ivanpribela@gmail.com>
Sun, 1 Nov 2015 14:57:03 +0000 (15:57 +0100)
Stabla/Primeri za test/StabloIO.java [new file with mode: 0644]
Stabla/Primeri za test/StabloIOClassic.java [new file with mode: 0644]
Stabla/Primeri za test/StabloIOIndent.java [new file with mode: 0644]
Stabla/Primeri za test/StabloIOPretty.java [new file with mode: 0644]
Stabla/Primeri za test/StabloIORandom.java [new file with mode: 0644]
Stabla/Primeri za test/StabloProgram.java [new file with mode: 0644]
Stabla/Primeri za test/classic.txt [new file with mode: 0644]
Stabla/Primeri za test/indent.txt [new file with mode: 0644]
Stabla/Primeri za test/pretty.txt [new file with mode: 0644]

diff --git a/Stabla/Primeri za test/StabloIO.java b/Stabla/Primeri za test/StabloIO.java
new file mode 100644 (file)
index 0000000..59984d3
--- /dev/null
@@ -0,0 +1,9 @@
+import org.svetovid.io.SvetovidReader;\r
+import org.svetovid.io.SvetovidWriter;\r
+\r
+public interface StabloIO {\r
+\r
+    public Stablo readStablo(SvetovidReader in);\r
+    public void printStablo(SvetovidWriter out, Stablo stablo);\r
+\r
+}\r
diff --git a/Stabla/Primeri za test/StabloIOClassic.java b/Stabla/Primeri za test/StabloIOClassic.java
new file mode 100644 (file)
index 0000000..dcf1d9f
--- /dev/null
@@ -0,0 +1,85 @@
+import java.util.NoSuchElementException;\r
+\r
+import org.svetovid.io.SvetovidReader;\r
+import org.svetovid.io.SvetovidWriter;\r
+\r
+/**\r
+ * Format:\r
+ *\r
+ * br\r
+ * id leviId desniId vrednost (x br)\r
+ */\r
+public class StabloIOClassic implements StabloIO {\r
+\r
+    @Override\r
+    public Stablo readStablo(SvetovidReader in) {\r
+        int br = in.readInt();\r
+        Stablo stablo = null;\r
+        for (int i = 0; i < br; i++) {\r
+            int id = in.readInt();\r
+            int leviId = in.readInt();\r
+            int desniId = in.readInt();\r
+            String vrednost = in.readLine();\r
+            Stablo levi = leviId == -1 ? null : new Stablo(leviId);\r
+            Stablo desni =desniId == -1 ? null : new Stablo(desniId);\r
+            Stablo element = new Stablo(id, vrednost, levi, desni);\r
+            stablo = insert(stablo, element);\r
+        }\r
+        return stablo;\r
+    }\r
+\r
+    private static Stablo insert(Stablo stablo, Stablo element) {\r
+        if (stablo == null) {\r
+            return element;\r
+        }\r
+        Stablo found = find(stablo, element.id);\r
+        if (found == null) {\r
+            throw new NoSuchElementException("id: " + element.id);\r
+        }\r
+        found.vrednost = element.vrednost;\r
+        found.levi = element.levi;\r
+        found.desni = element.desni;\r
+        return stablo;\r
+    }\r
+\r
+    private static Stablo find(Stablo stablo, int id) {\r
+        if (stablo == null) {\r
+            return null;\r
+        }\r
+        if (stablo.id == id) {\r
+            return stablo;\r
+        }\r
+        Stablo rezultat = find(stablo.levi, id);\r
+        if (rezultat != null) {\r
+            return rezultat;\r
+        }\r
+        return find(stablo.desni, id);\r
+    }\r
+\r
+    @Override\r
+    public void printStablo(SvetovidWriter out, Stablo stablo) {\r
+        int br = count(stablo);\r
+        out.println(br);\r
+        iterate(out, stablo);\r
+    }\r
+\r
+    private static int count(Stablo stablo) {\r
+        if (stablo == null) {\r
+            return 0;\r
+        }\r
+        return 1 + count(stablo.levi) + count(stablo.desni);\r
+    }\r
+\r
+    private static void iterate(SvetovidWriter out, Stablo stablo) {\r
+        if (stablo == null) {\r
+            return;\r
+        }\r
+        int id = stablo.id;\r
+        int leviId = stablo.levi == null ? -1 : stablo.levi.id;\r
+        int desniId = stablo.desni == null ? -1 : stablo.desni.id;\r
+        String vrednost = stablo.vrednost;\r
+        out.println(id, leviId, desniId, vrednost);\r
+        iterate(out, stablo.levi);\r
+        iterate(out, stablo.desni);\r
+    }\r
+}\r
diff --git a/Stabla/Primeri za test/StabloIOIndent.java b/Stabla/Primeri za test/StabloIOIndent.java
new file mode 100644 (file)
index 0000000..8e9dc83
--- /dev/null
@@ -0,0 +1,73 @@
+import org.svetovid.SvetovidFormatException;\r
+import org.svetovid.io.SvetovidReader;\r
+import org.svetovid.io.SvetovidWriter;\r
+\r
+/**\r
+ * Format:\r
+ *\r
+ * id vrednost\r
+ * levi\r
+ * desni\r
+ */\r
+public class StabloIOIndent implements StabloIO {\r
+\r
+    protected String nullSymbol;\r
+    protected String indent;\r
+\r
+    public StabloIOIndent() {\r
+        this("-", "    ");\r
+    }\r
+\r
+    public StabloIOIndent(String nullSymbol, String indent) {\r
+        this.nullSymbol = nullSymbol;\r
+        this.indent = indent;\r
+    }\r
+\r
+    public String getNullSymbol() {\r
+        return nullSymbol;\r
+    }\r
+\r
+    public void setNullSymbol(String nullSymbol) {\r
+        this.nullSymbol = nullSymbol;\r
+    }\r
+\r
+    public String getIndent() {\r
+        return indent;\r
+    }\r
+\r
+    public void setIndent(String indent) {\r
+        this.indent = indent;\r
+    }\r
+\r
+    @Override\r
+    public Stablo readStablo(SvetovidReader in) {\r
+        try {\r
+            int id = in.readInt();\r
+            String vrednost = in.readLine();\r
+            Stablo levi = readStablo(in);\r
+            Stablo desni = readStablo(in);\r
+            Stablo stablo = new Stablo(id, vrednost, levi, desni);\r
+            return stablo;\r
+        } catch (SvetovidFormatException e) {\r
+            return null;\r
+        }\r
+    }\r
+\r
+    @Override\r
+    public void printStablo(SvetovidWriter out, Stablo stablo) {\r
+        write(out, stablo, nullSymbol, indent, "");\r
+    }\r
+\r
+    protected void write(SvetovidWriter out, Stablo stablo, String nullSymbol, String indent, String prefix) {\r
+        if (stablo == null) {\r
+            out.println(prefix + nullSymbol);\r
+            return;\r
+        }\r
+        int id = stablo.id;\r
+        String vrednost = stablo.vrednost;\r
+        out.print(prefix);\r
+        out.println(id, vrednost);\r
+        write(out, stablo.levi, nullSymbol, indent, prefix + indent);\r
+        write(out, stablo.desni, nullSymbol, indent, prefix + indent);\r
+    }\r
+}\r
diff --git a/Stabla/Primeri za test/StabloIOPretty.java b/Stabla/Primeri za test/StabloIOPretty.java
new file mode 100644 (file)
index 0000000..6fcc069
--- /dev/null
@@ -0,0 +1,224 @@
+import java.util.ArrayList;\r
+import java.util.List;\r
+import java.util.regex.Matcher;\r
+import java.util.regex.Pattern;\r
+\r
+import org.svetovid.io.SvetovidReader;\r
+import org.svetovid.io.SvetovidWriter;\r
+\r
+/**\r
+ * Format:\r
+ *   /-- desni\r
+ * -(id) vrednost\r
+ *   \-- levi\r
+ */\r
+public class StabloIOPretty implements StabloIO {\r
+\r
+    protected static final String EMPTY_SYMBOL = " ";\r
+    protected static final String RIGHT_SYMBOL = "/";\r
+    protected static final String VERTICAL_SYMBOL = "|";\r
+    protected static final String LEFT_SYMBOL = "\\";\r
+    protected static final String HORIZONTAL_SYMBOL = "-";\r
+\r
+    protected String nullSymbol;\r
+    protected boolean separated;\r
+    protected int length;\r
+\r
+    public StabloIOPretty() {\r
+        this(null, false, 7);\r
+    }\r
+\r
+    public StabloIOPretty(String nullSymbol, boolean separated, int length) {\r
+        this.nullSymbol = nullSymbol;\r
+        this.separated = separated;\r
+        this.length = length;\r
+    }\r
+\r
+    public String getNullSymbol() {\r
+        return nullSymbol;\r
+    }\r
+\r
+    public void setNullSymbol(String nullSymbol) {\r
+        this.nullSymbol = nullSymbol;\r
+    }\r
+\r
+    public boolean isSeparated() {\r
+        return separated;\r
+    }\r
+\r
+    public void setSeparated(boolean separated) {\r
+        this.separated = separated;\r
+    }\r
+\r
+    public int getLength() {\r
+        return length;\r
+    }\r
+\r
+    public void setLength(int length) {\r
+        if (length < 3) {\r
+            throw new IllegalArgumentException("length");\r
+        }\r
+        this.length = length;\r
+    }\r
+\r
+    @Override\r
+    public Stablo readStablo(SvetovidReader in) {\r
+        return parseStablo(in, nullSymbol, length);\r
+    }\r
+\r
+    protected Stablo parseStablo(SvetovidReader in, String nullSymbol, int length) {\r
+        List<Stablo> elements = new ArrayList<>();\r
+        List<Integer> levels = new ArrayList<>();\r
+        Pattern levelPattern = Pattern.compile("[\\Q" + LEFT_SYMBOL + HORIZONTAL_SYMBOL + RIGHT_SYMBOL + "\\E]");\r
+        String line = in.readLine();\r
+        while ((line != null) && !line.isEmpty()) {\r
+            Matcher matcher = levelPattern.matcher(line);\r
+            int level = -1;\r
+            if (matcher.find()) {\r
+                level = matcher.start();\r
+            }\r
+            if (level != -1 && (nullSymbol == null || !line.endsWith(nullSymbol))) {\r
+                Stablo stablo = parseStablo(line);\r
+                elements.add(stablo);\r
+                levels.add(level);\r
+            }\r
+            line = in.readLine();\r
+        }\r
+        Stablo stablo = formStablo(0, elements.size(), levels, elements);\r
+        return stablo;\r
+    }\r
+\r
+    private Stablo parseStablo(String line) {\r
+        int id = -1;\r
+        String vrednost = null;\r
+        int beginIndex = line.indexOf('(');\r
+        int endIndex = line.indexOf(')');\r
+        if ((beginIndex != -1) && (endIndex != -1) && (beginIndex < endIndex)) {\r
+            vrednost = line.substring(beginIndex + 1, endIndex);\r
+            try {\r
+                id = Integer.parseInt(vrednost);\r
+            } catch (NumberFormatException e) {\r
+                throw new NumberFormatException(line);\r
+            }\r
+            vrednost = line.substring(endIndex + 2);\r
+        } else {\r
+            throw new NumberFormatException(line);\r
+        }\r
+        Stablo stablo = new Stablo(id, vrednost);\r
+        return stablo;\r
+    }\r
+\r
+    private Stablo formStablo(int beginIndex, int endIndex, List<Integer> levels, List<Stablo> elements) {\r
+        if (beginIndex >= endIndex) {\r
+            return null;\r
+        }\r
+        int minIndex = beginIndex;\r
+        int minLevel = levels.get(minIndex);\r
+        for (int i = beginIndex + 1; i < endIndex; i++) {\r
+            int level = levels.get(i);\r
+            if (level < minLevel) {\r
+                minLevel = level;\r
+                minIndex = i;\r
+            }\r
+        }\r
+        Stablo stablo = elements.get(minIndex);\r
+        Stablo levi = formStablo(minIndex + 1, endIndex, levels, elements);\r
+        Stablo desni = formStablo(beginIndex, minIndex, levels, elements);\r
+        stablo.levi = levi;\r
+        stablo.desni = desni;\r
+        return stablo;\r
+    }\r
+\r
+    @Override\r
+    public void printStablo(SvetovidWriter out, Stablo stablo) {\r
+        StringBuilder builder = new StringBuilder();\r
+        appendTree(builder, stablo, nullSymbol, separated, length);\r
+        out.print(builder.toString());\r
+    }\r
+\r
+    protected void appendTree(StringBuilder builder, Stablo stablo, String nullSymbol, boolean separated, int length) {\r
+        String[] buildingBlocks = generateBuildingBlocks(length);\r
+        appendRight(builder, stablo, nullSymbol, separated, buildingBlocks, true, buildingBlocks[5]);\r
+        appendNode(builder, stablo, nullSymbol != null ? nullSymbol : "|", buildingBlocks[4]);\r
+        appendLeft(builder, stablo, nullSymbol, separated, buildingBlocks, false, buildingBlocks[5]);\r
+    }\r
+\r
+    protected void appendNode(StringBuilder builder, Stablo stablo, String nullSymbol, String prefix) {\r
+        builder.append(prefix);\r
+        if (stablo == null) {\r
+            builder.append(nullSymbol);\r
+        } else {\r
+            builder.append("(");\r
+            builder.append(stablo.id);\r
+            builder.append(") ");\r
+            builder.append(stablo.vrednost);\r
+        }\r
+        builder.append("\n");\r
+    }\r
+\r
+    protected void appendRight(StringBuilder builder, Stablo stablo, String nullSymbol, boolean separated, String[] buildingBlocks, boolean isRight, String prefix) {\r
+        if (stablo == null) {\r
+            return;\r
+        }\r
+        if ((nullSymbol != null) || (stablo.desni != null)) {\r
+            appendSubtree(builder, stablo.desni, nullSymbol, separated, buildingBlocks, true, prefix);\r
+            if (separated) {\r
+                appendEmpty(builder, buildingBlocks, prefix);\r
+            }\r
+        }\r
+    }\r
+\r
+    protected void appendLeft(StringBuilder builder, Stablo stablo, String nullSymbol, boolean separated, String[] buildingBlocks, boolean isRight, String prefix) {\r
+        if (stablo == null) {\r
+            return;\r
+        }\r
+        if ((nullSymbol != null) || (stablo.levi != null)) {\r
+            if (separated) {\r
+                appendEmpty(builder, buildingBlocks, prefix);\r
+            }\r
+            appendSubtree(builder, stablo.levi, nullSymbol, separated, buildingBlocks, false, prefix);\r
+        }\r
+    }\r
+\r
+    protected void appendEmpty(StringBuilder builder, String[] buildingBlocks, String prefix) {\r
+        builder.append(prefix);\r
+        builder.append(buildingBlocks[2]);\r
+        builder.append("\n");\r
+    }\r
+\r
+    protected void appendSubtree(StringBuilder builder, Stablo stablo, String nullSymbol, boolean separated, String[] buildingBlocks, boolean isRight, String prefix) {\r
+        String mojPrefix = prefix;\r
+        if (isRight == true) {\r
+            mojPrefix = mojPrefix + buildingBlocks[1];\r
+        }\r
+        if (isRight == false) {\r
+            mojPrefix = mojPrefix + buildingBlocks[3];\r
+        }\r
+        String noviPrefix = prefix + (!isRight ? buildingBlocks[2] : buildingBlocks[0]);\r
+        appendRight(builder, stablo, nullSymbol, separated, buildingBlocks, isRight, noviPrefix);\r
+        appendNode(builder, stablo, nullSymbol, mojPrefix);\r
+        noviPrefix = prefix + (isRight ? buildingBlocks[2] : buildingBlocks[0]);\r
+        appendLeft(builder, stablo, nullSymbol, separated, buildingBlocks, isRight, noviPrefix);\r
+    }\r
+\r
+    private String[] generateBuildingBlocks(int length) {\r
+        String[] blocks = new String[6];\r
+        blocks[0] = generateBlock(EMPTY_SYMBOL, EMPTY_SYMBOL, EMPTY_SYMBOL, length - 2);\r
+        blocks[1] = generateBlock(EMPTY_SYMBOL, RIGHT_SYMBOL, HORIZONTAL_SYMBOL, length - 2);\r
+        blocks[2] = generateBlock(EMPTY_SYMBOL, VERTICAL_SYMBOL, EMPTY_SYMBOL, length - 2);\r
+        blocks[3] = generateBlock(EMPTY_SYMBOL, LEFT_SYMBOL, HORIZONTAL_SYMBOL, length - 2);\r
+        blocks[4] = HORIZONTAL_SYMBOL;\r
+        blocks[5] = EMPTY_SYMBOL;\r
+        return blocks;\r
+    }\r
+\r
+    protected String generateBlock(String emptySymbol, String startSymbol, String repeatSymbol, int repeatCount) {\r
+        StringBuilder builder = new StringBuilder();\r
+        builder.append(emptySymbol);\r
+        builder.append(startSymbol);\r
+        for (int i = 0; i < repeatCount; i++) {\r
+            builder.append(repeatSymbol);\r
+        }\r
+        return builder.toString();\r
+    }\r
+}\r
diff --git a/Stabla/Primeri za test/StabloIORandom.java b/Stabla/Primeri za test/StabloIORandom.java
new file mode 100644 (file)
index 0000000..d3a98ca
--- /dev/null
@@ -0,0 +1,75 @@
+import java.math.BigInteger;\r
+import java.util.Random;\r
+import java.util.concurrent.atomic.AtomicInteger;\r
+\r
+import org.svetovid.io.SvetovidReader;\r
+import org.svetovid.io.SvetovidWriter;\r
+\r
+public class StabloIORandom implements StabloIO {\r
+\r
+    protected long seed;\r
+    protected int length;\r
+    protected int depth;\r
+\r
+    public StabloIORandom() {\r
+        this(System.currentTimeMillis());\r
+    }\r
+\r
+    public StabloIORandom(long seed) {\r
+        this(seed, 5, 10);\r
+    }\r
+\r
+    public StabloIORandom(long seed, int length, int depth) {\r
+        this.seed = seed;\r
+        this.length = length;\r
+        this.depth = depth;\r
+    }\r
+\r
+    public long getSeed() {\r
+        return seed;\r
+    }\r
+\r
+    public void setSeed(long seed) {\r
+        this.seed = seed;\r
+    }\r
+\r
+    public int getLength() {\r
+        return length;\r
+    }\r
+\r
+    public void setLength(int length) {\r
+        this.length = length;\r
+    }\r
+\r
+    public int getDepth() {\r
+        return depth;\r
+    }\r
+\r
+    public void setDepth(int depth) {\r
+        this.depth = depth;\r
+    }\r
+\r
+    @Override\r
+    public Stablo readStablo(SvetovidReader in) {\r
+        Random random = new Random(seed);\r
+        AtomicInteger sequence = new AtomicInteger();\r
+        Stablo stablo = readStablo(random, sequence, length, depth);\r
+        return stablo;\r
+    }\r
+\r
+    private Stablo readStablo(Random random, AtomicInteger sequence, int length, int depth) {\r
+       if (depth <= 0) {\r
+               return null;\r
+       }\r
+        int id = sequence.addAndGet(1 + random.nextInt(9));\r
+        String vrednost = new BigInteger(length, random).toString(36);\r
+        Stablo desni = readStablo(random, sequence, length + random.nextInt(5), depth - random.nextInt(5));\r
+        Stablo levi = readStablo(random, sequence, length + random.nextInt(5), depth - random.nextInt(5));\r
+        return new Stablo(id, vrednost, levi, desni);\r
+    }\r
+\r
+    @Override\r
+    public void printStablo(SvetovidWriter out, Stablo stablo) {\r
+        throw new UnsupportedOperationException();\r
+    }\r
+}\r
diff --git a/Stabla/Primeri za test/StabloProgram.java b/Stabla/Primeri za test/StabloProgram.java
new file mode 100644 (file)
index 0000000..148ce7b
--- /dev/null
@@ -0,0 +1,123 @@
+import java.util.ArrayList;\r
+import java.util.List;\r
+\r
+class Stablo {\r
+\r
+    public final int id;\r
+    public String vrednost;\r
+    public Stablo levi;\r
+    public Stablo desni;\r
+\r
+    public Stablo(int id) {\r
+        this(id, null);\r
+    }\r
+\r
+    public Stablo(int id, String vrednost) {\r
+        this(id, vrednost, null, null);\r
+    }\r
+\r
+    public Stablo(int id, String vrednost, Stablo levi, Stablo desni) {\r
+        this.id = id;\r
+        this.vrednost = vrednost;\r
+        this.levi = levi;\r
+        this.desni = desni;\r
+    }\r
+\r
+    @Override\r
+    public String toString() {\r
+        return "(" + id + " \"" + vrednost + "\"" + (levi == null ? "" : " " + levi) + (desni == null ? "" : " " + desni) + ")";\r
+    }\r
+}\r
+\r
+public class StabloProgram {\r
+\r
+    public static void main(String[] args) {\r
+\r
+        // Ucitavanje stabla\r
+        StabloIO inIO = new StabloIORandom(12345);\r
+        Stablo stablo = inIO.readStablo(null);\r
+\r
+        // Ispisivanje stabla na ekran\r
+        StabloIO outIO = new StabloIOPretty();\r
+        outIO.printStablo(Svetovid.out, stablo);\r
+        Svetovid.out.println();\r
+\r
+        // Broj nivoa\r
+        int brojNivoa = brojNivoa(stablo);\r
+        Svetovid.out.println("Broj nivoa:", brojNivoa);\r
+        Svetovid.out.println();\r
+\r
+        // Broj nivoa\r
+        int brojElementata = brojElementata(stablo);\r
+        Svetovid.out.println("Broj elementata:", brojElementata);\r
+        Svetovid.out.println();\r
+\r
+        // Broj nivoa\r
+        String najduzaVrednost = najduzaVrednost(stablo);\r
+        Svetovid.out.println("Najduza vrednost:", najduzaVrednost);\r
+        Svetovid.out.println();\r
+\r
+        // Svi Putevi od korena do listova\r
+        sviPutevi(stablo, new ArrayList<>(brojNivoa));\r
+        Svetovid.out.println();\r
+\r
+        // Obrnuto stablo\r
+        Stablo obrnuto = obrni(stablo);\r
+        outIO.printStablo(Svetovid.out, obrnuto);\r
+        Svetovid.out.println();\r
+\r
+    }\r
+\r
+    private static int brojElementata(Stablo stablo) {\r
+        if (stablo == null) {\r
+            return 0;\r
+        }\r
+        return 1 + brojElementata(stablo.levi) + brojElementata(stablo.desni);\r
+    }\r
+\r
+    private static int brojNivoa(Stablo stablo) {\r
+        if (stablo == null) {\r
+            return 0;\r
+        }\r
+        return 1 + Math.max(brojNivoa(stablo.levi), brojNivoa(stablo.desni));\r
+    }\r
+\r
+    private static String najduzaVrednost(Stablo stablo) {\r
+        if (stablo == null) {\r
+            return null;\r
+        }\r
+        String rezultat = stablo.vrednost;\r
+        String levaVrednost = najduzaVrednost(stablo.levi);\r
+        String desnaVrednost = najduzaVrednost(stablo.desni);\r
+        if (rezultat == null || (levaVrednost != null && rezultat.length() < levaVrednost.length())) {\r
+            rezultat = levaVrednost;\r
+        }\r
+        if (rezultat == null || (desnaVrednost != null && rezultat.length() < desnaVrednost.length())) {\r
+            rezultat = desnaVrednost;\r
+        }\r
+        return rezultat;\r
+    }\r
+\r
+    private static void sviPutevi(Stablo stablo, List<String> put) {\r
+        if (stablo == null) {\r
+            return;\r
+        }\r
+        put.add(stablo.vrednost);\r
+        if ((stablo.levi == null) && (stablo.desni == null)) {\r
+            Svetovid.out.println("Put: " + put);\r
+        }\r
+        sviPutevi(stablo.levi, put);\r
+        sviPutevi(stablo.desni, put);\r
+        put.remove(put.size() - 1);\r
+    }\r
+\r
+    private static Stablo obrni(Stablo stablo) {\r
+        if (stablo == null) {\r
+            return null;\r
+        }\r
+        Stablo levi = obrni(stablo.levi);\r
+        Stablo desni = obrni(stablo.desni);\r
+        Stablo obrnuto = new Stablo(stablo.id, stablo.vrednost, desni, levi);\r
+        return obrnuto;\r
+    }\r
+}\r
diff --git a/Stabla/Primeri za test/classic.txt b/Stabla/Primeri za test/classic.txt
new file mode 100644 (file)
index 0000000..8afb799
--- /dev/null
@@ -0,0 +1,50 @@
+49\r
+5 94 10 h\r
+94 136 97 a\r
+136 214 143 54\r
+214 219 -1 3g\r
+219 226 -1 ph\r
+226 -1 229 y4\r
+229 -1 230 515\r
+230 237 -1 mo0\r
+237 251 245 1adr\r
+251 -1 -1 a5f1\r
+245 -1 -1 2jl1\r
+143 -1 147 ak\r
+147 161 152 4a0\r
+161 182 165 14\r
+182 189 -1 50f5\r
+189 192 -1 2uh8\r
+192 193 -1 27r6\r
+193 194 -1 1ol4m\r
+194 209 201 2a3aq\r
+209 -1 -1 7aa8b\r
+201 -1 -1 2l3k6\r
+165 171 167 4ac3\r
+171 173 -1 1g7an\r
+173 -1 -1 8deri\r
+167 -1 -1 fe2n\r
+152 -1 -1 2p7\r
+97 106 -1 1m\r
+106 134 109 81\r
+134 -1 -1 1pu\r
+109 117 -1 1by\r
+117 129 123 iu0\r
+129 -1 -1 8tl8\r
+123 -1 -1 3bds\r
+10 67 18 9\r
+67 72 71 e6\r
+72 85 76 6n\r
+85 87 -1 km1\r
+87 -1 -1 2u0n\r
+76 -1 -1 1nm\r
+71 -1 -1 36\r
+18 29 26 1m\r
+29 58 32 67\r
+58 -1 -1 32\r
+32 51 41 mg\r
+51 -1 52 14y\r
+52 -1 -1 7uq\r
+41 44 -1 h1\r
+44 -1 -1 1ec\r
+26 -1 -1 19\r
diff --git a/Stabla/Primeri za test/indent.txt b/Stabla/Primeri za test/indent.txt
new file mode 100644 (file)
index 0000000..caecf7a
--- /dev/null
@@ -0,0 +1,99 @@
+5 h\r
+    94 a\r
+        136 54\r
+            214 3g\r
+                219 ph\r
+                    226 y4\r
+                        -\r
+                        229 515\r
+                            -\r
+                            230 mo0\r
+                                237 1adr\r
+                                    251 a5f1\r
+                                        -\r
+                                        -\r
+                                    245 2jl1\r
+                                        -\r
+                                        -\r
+                                -\r
+                    -\r
+                -\r
+            143 ak\r
+                -\r
+                147 4a0\r
+                    161 14\r
+                        182 50f5\r
+                            189 2uh8\r
+                                192 27r6\r
+                                    193 1ol4m\r
+                                        194 2a3aq\r
+                                            209 7aa8b\r
+                                                -\r
+                                                -\r
+                                            201 2l3k6\r
+                                                -\r
+                                                -\r
+                                        -\r
+                                    -\r
+                                -\r
+                            -\r
+                        165 4ac3\r
+                            171 1g7an\r
+                                173 8deri\r
+                                    -\r
+                                    -\r
+                                -\r
+                            167 fe2n\r
+                                -\r
+                                -\r
+                    152 2p7\r
+                        -\r
+                        -\r
+        97 1m\r
+            106 81\r
+                134 1pu\r
+                    -\r
+                    -\r
+                109 1by\r
+                    117 iu0\r
+                        129 8tl8\r
+                            -\r
+                            -\r
+                        123 3bds\r
+                            -\r
+                            -\r
+                    -\r
+            -\r
+    10 9\r
+        67 e6\r
+            72 6n\r
+                85 km1\r
+                    87 2u0n\r
+                        -\r
+                        -\r
+                    -\r
+                76 1nm\r
+                    -\r
+                    -\r
+            71 36\r
+                -\r
+                -\r
+        18 1m\r
+            29 67\r
+                58 32\r
+                    -\r
+                    -\r
+                32 mg\r
+                    51 14y\r
+                        -\r
+                        52 7uq\r
+                            -\r
+                            -\r
+                    41 h1\r
+                        44 1ec\r
+                            -\r
+                            -\r
+                        -\r
+            26 19\r
+                -\r
+                -\r
diff --git a/Stabla/Primeri za test/pretty.txt b/Stabla/Primeri za test/pretty.txt
new file mode 100644 (file)
index 0000000..5f1b623
--- /dev/null
@@ -0,0 +1,49 @@
+                /-----(26) 19\r
+         /-----(18) 1m\r
+         |      |             /-----(41) h1\r
+         |      |             |      \-----(44) 1ec\r
+         |      |      /-----(32) mg\r
+         |      |      |      |      /-----(52) 7uq\r
+         |      |      |      \-----(51) 14y\r
+         |      \-----(29) 67\r
+         |             \-----(58) 32\r
+  /-----(10) 9\r
+  |      |      /-----(71) 36\r
+  |      \-----(67) e6\r
+  |             |      /-----(76) 1nm\r
+  |             \-----(72) 6n\r
+  |                    \-----(85) km1\r
+  |                           \-----(87) 2u0n\r
+-(5) h\r
+  |      /-----(97) 1m\r
+  |      |      |      /-----(109) 1by\r
+  |      |      |      |      |      /-----(123) 3bds\r
+  |      |      |      |      \-----(117) iu0\r
+  |      |      |      |             \-----(129) 8tl8\r
+  |      |      \-----(106) 81\r
+  |      |             \-----(134) 1pu\r
+  \-----(94) a\r
+         |                    /-----(152) 2p7\r
+         |             /-----(147) 4a0\r
+         |             |      |             /-----(167) fe2n\r
+         |             |      |      /-----(165) 4ac3\r
+         |             |      |      |      \-----(171) 1g7an\r
+         |             |      |      |             \-----(173) 8deri\r
+         |             |      \-----(161) 14\r
+         |             |             \-----(182) 50f5\r
+         |             |                    \-----(189) 2uh8\r
+         |             |                           \-----(192) 27r6\r
+         |             |                                  \-----(193) 1ol4m\r
+         |             |                                         |      /-----(201) 2l3k6\r
+         |             |                                         \-----(194) 2a3aq\r
+         |             |                                                \-----(209) 7aa8b\r
+         |      /-----(143) ak\r
+         \-----(136) 54\r
+                \-----(214) 3g\r
+                       \-----(219) ph\r
+                              |             /-----(230) mo0\r
+                              |             |      |      /-----(245) 2jl1\r
+                              |             |      \-----(237) 1adr\r
+                              |             |             \-----(251) a5f1\r
+                              |      /-----(229) 515\r
+                              \-----(226) y4\r
Svarog.pmf.uns.ac.rs/gitweb maintanance Doni Pracner