EMAN2
Public Member Functions | Private Attributes | List of all members
EMAN::ImageSort Class Reference

#include <emutil.h>

Collaboration diagram for EMAN::ImageSort:
Collaboration graph
[legend]

Public Member Functions

 ImageSort (int n)
 
 ~ImageSort ()
 
void sort ()
 
void set (int i, float score)
 
int get_index (int i) const
 
float get_score (int i) const
 
int size () const
 

Private Attributes

ImageScoreimage_scores
 
int n
 

Detailed Description

Definition at line 422 of file emutil.h.

Constructor & Destructor Documentation

◆ ImageSort()

ImageSort::ImageSort ( int  n)

Definition at line 1322 of file emutil.cpp.

1323{
1324 Assert(nn > 0);
1325 n = nn;
1326 image_scores = new ImageScore[n];
1327}
ImageScore * image_scores
Definition: emutil.h:435
#define Assert(s)
Define Assert() function that is effective only when -DDEBUG is used.
Definition: emassert.h:42

References Assert, image_scores, and n.

◆ ~ImageSort()

ImageSort::~ImageSort ( )

Definition at line 1329 of file emutil.cpp.

1330{
1331 if (image_scores) {
1332 delete [] image_scores;
1333 image_scores = NULL;
1334 }
1335}

References image_scores.

Member Function Documentation

◆ get_index()

int ImageSort::get_index ( int  i) const

Definition at line 1348 of file emutil.cpp.

1349{
1350 Assert(i >= 0);
1351 return image_scores[i].index;
1352}

References Assert, image_scores, and EMAN::ImageScore::index.

◆ get_score()

float ImageSort::get_score ( int  i) const

Definition at line 1354 of file emutil.cpp.

1355{
1356 Assert(i >= 0);
1357 return image_scores[i].score;
1358}

References Assert, image_scores, and EMAN::ImageScore::score.

◆ set()

void ImageSort::set ( int  i,
float  score 
)

Definition at line 1342 of file emutil.cpp.

1343{
1344 Assert(i >= 0);
1345 image_scores[i] = ImageScore(i, score);
1346}

References Assert, and image_scores.

◆ size()

int ImageSort::size ( ) const

Definition at line 1360 of file emutil.cpp.

1361{
1362 return n;
1363}

References n.

◆ sort()

void ImageSort::sort ( )

Definition at line 1337 of file emutil.cpp.

1338{
1339 qsort(image_scores, n, sizeof(ImageScore), imgscore_cmp);
1340}
static int imgscore_cmp(const void *imgscore1, const void *imgscore2)
Definition: emutil.cpp:1305

References image_scores, imgscore_cmp(), and n.

Member Data Documentation

◆ image_scores

ImageScore* EMAN::ImageSort::image_scores
private

Definition at line 435 of file emutil.h.

Referenced by get_index(), get_score(), ImageSort(), set(), sort(), and ~ImageSort().

◆ n

int EMAN::ImageSort::n
private

Definition at line 436 of file emutil.h.

Referenced by ImageSort(), size(), and sort().


The documentation for this class was generated from the following files: