/vqdr/trunk

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/vqdr/trunk

« back to all changes in this revision

Viewing changes to src/utils/pair.vala

  • Committer: Gustav Hartvigsson
  • Date: 2024-12-21 22:39:17 UTC
  • Revision ID: gustav.hartvigsson@gmail.com-20241221223917-jbt2ylyz9nxjss49
various changes
[utils/utils.vala]
* Removed uneeded int32_abs function

[utils/stack]
* more informative error when trying to pop an empty stack.

[utils/random.vala]
* added c_names to functions (probobly not needed).

[utils/pair.vala]
* Made compact
* made FreeFunc delegates unowned to fix error
* added constructor Pair.with_free_func ().

[utils/named_vector.vala]
* made class compact.

[utils/meson.build]
* Reordered files in list
* added logger.vala.

[utils/logger.vala]
* Added fast and easy logger class.

[utils/fast_number.vala]
* added a bunch of cname CCode attributes.

[general]
* Spelling in comments and functions.

[meson.build]
* Made dependancies easier to read
* added vala posix dependency

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
[CCode (cname = "V", cprefix = "v_")]
7
7
namespace  Utils {
8
8
  [CCode (cname = "VPair", cprefix = "v_pair_")]
 
9
  [Compact]
9
10
  public class Pair<T1, T2> {
10
11
    public T1 v1;
11
12
    public T2 v2;
12
 
 
 
13
    public unowned FreeFunc v1_free_func;
 
14
    public unowned FreeFunc v2_free_func;
 
15
    [CCode (cname = "v_pair_new")]
13
16
    public Pair (T1 v1, T2 v2) {
14
17
      this.v1 = v1;
15
18
      this.v2 = v2;
16
19
    }
 
20
    [CCode (cname = "v_pair_new_with_free_func")]
 
21
    public Pair.with_free_func (T1 v1, T2 v2,
 
22
                               FreeFunc v1_free_func,
 
23
                               FreeFunc v2_free_func) {
 
24
      this.v1 = v1;
 
25
      this.v2 = v2;
 
26
      this.v1_free_func = v1_free_func;
 
27
      this.v2_free_func = v2_free_func;
 
28
    }
 
29
    
 
30
    [CCode (cname = "v_pair_destroy")]
 
31
    ~Pair () {
 
32
      if (this.v1_free_func != null) {
 
33
        this.v1_free_func (v1);
 
34
      }
 
35
      if (this.v2_free_func != null) {
 
36
        this.v2_free_func (v2);
 
37
      }
 
38
    }
17
39
  }
18
40
}