The Birdfont Source Code


All Repositories / birdfont.git / blob – RSS feed

PathList.vala in libbirdfont

This file is a part of the Birdfont project.

Contributing

Send patches or pull requests to johan.mattsson.m@gmail.com.
Clone this repository: git clone https://github.com/johanmattssonm/birdfont.git
Install renamed icons file heads/master
1 /* 2 Copyright (C) 2013 Johan Mattsson 3 4 This library is free software; you can redistribute it and/or modify 5 it under the terms of the GNU Lesser General Public License as 6 published by the Free Software Foundation; either version 3 of the 7 License, or (at your option) any later version. 8 9 This library is distributed in the hope that it will be useful, but 10 WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 Lesser General Public License for more details. 13 */ 14 15 namespace BirdFont { 16 17 public class PathList : GLib.Object { 18 public Gee.ArrayList<Path> paths; 19 20 public PathList () { 21 paths = new Gee.ArrayList<Path> (); 22 } 23 24 public PathList.for_path (Path p) { 25 paths = new Gee.ArrayList<Path> (); 26 paths.add (p); 27 } 28 29 public void remove (Path p) { 30 paths.remove (p); 31 } 32 33 public void add_unique (Path p) { 34 if (paths.index_of (p) == -1) { 35 paths.add (p); 36 } 37 } 38 39 public void add (Path p) { 40 paths.add (p); 41 } 42 43 public void append (PathList pl) { 44 foreach (Path p in pl.paths) { 45 paths.add (p); 46 } 47 } 48 49 public void clear () { 50 paths.clear (); 51 } 52 53 public Path get_first_path () { 54 if (unlikely (paths.size == 0)) { 55 warning ("No path"); 56 return new Path (); 57 } 58 59 return paths.get (0); 60 } 61 62 public Path merge_all () { 63 Path p = get_first_path (); 64 65 for (int i = 1; i < paths.size; i++) { 66 p.append_path (paths.get (i)); 67 } 68 69 return p; 70 } 71 72 public PathList copy () { 73 PathList pl = new PathList (); 74 75 foreach (Path p in paths) { 76 pl.add (p.copy ()); 77 } 78 79 return pl; 80 } 81 } 82 83 } 84