File: GxB_Vector_Iterator.c

package info (click to toggle)
suitesparse-graphblas 7.4.0%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 67,112 kB
  • sloc: ansic: 1,072,243; cpp: 8,081; sh: 512; makefile: 506; asm: 369; python: 125; awk: 10
file content (77 lines) | stat: -rw-r--r-- 2,110 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
//------------------------------------------------------------------------------
// GxB_Vector_Iterator: iterate over the entries of a vector
//------------------------------------------------------------------------------

// SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2022, All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

//------------------------------------------------------------------------------

#include "GB.h"

#undef GxB_Vector_Iterator_getpmax
#undef GxB_Vector_Iterator_seek
#undef GxB_Vector_Iterator_next
#undef GxB_Vector_Iterator_getp
#undef GxB_Vector_Iterator_getIndex

GrB_Info GxB_Vector_Iterator_attach
(
    // input/output:
    GxB_Iterator iterator,      // iterator to attach to the vector v
    // input
    GrB_Vector v,               // vector to attach
    GrB_Descriptor desc
)
{ 
    return (GB_Iterator_attach (iterator, (GrB_Matrix) v, GxB_NO_FORMAT,
        desc)) ;
}

GrB_Info GB_Vector_Iterator_bitmap_seek
(
    GxB_Iterator iterator,
    GrB_Index unused // note: unused parameter to be removed in v8.x
)
{
    for ( ; iterator->p < iterator->pmax ; iterator->p++)
    {
        if (iterator->Ab [iterator->p])
        { 
            // found next entry
            return (GrB_SUCCESS) ;
        }
    }
    return (GxB_EXHAUSTED) ;
}

GrB_Index GxB_Vector_Iterator_getpmax (GxB_Iterator iterator)
{ 
    // return the range of the vector iterator
    return (iterator->pmax) ;
}

GrB_Info GxB_Vector_Iterator_seek (GxB_Iterator iterator, GrB_Index p)
{ 
    // seek to a specific entry in the vector
    return (GB_Vector_Iterator_seek (iterator, p)) ;
}

GrB_Info GxB_Vector_Iterator_next (GxB_Iterator iterator)
{ 
    // move to the next entry of a vector
    return (GB_Vector_Iterator_next (iterator)) ;
}

GrB_Index GxB_Vector_Iterator_getp (GxB_Iterator iterator)
{ 
    // get the current position of a vector iterator
    return (iterator->p) ;
}

GrB_Index GxB_Vector_Iterator_getIndex (GxB_Iterator iterator)
{ 
    // get the index of a vector entry
    return ((iterator->Ai != NULL) ? iterator->Ai [iterator->p] : iterator->p) ;
}