⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 r2select.c

📁 这是一个C程序分析工具
💻 C
字号:
/*====================================================================*/
/*  UNIT   :  @(#)r2select.c	2.3  -  08/04/99 */
/*====================================================================*/
/*  PURPOSE:  This function traverses the Component List and for each */
/*            component calculates the ratio of frequency with        */
/*            functionality over total frequency.  If the ratio is    */
/*            less than the threshold then the component is removed   */
/*            from the list.                                          */
/*                                                                    */
/*  SYSTEM :  RECON II                                                */
/*                                                                    */
/*  USED BY:  main()                                                  */
/*                                                                    */
/*  HISTORY:                                                          */
/*  VER   DATE       AUTHOR        DESCRIPTION                        */
/*  1.00  23 Feb 93  L. Richard    Created unit.                      */
/*  1.01  10 Mar 93  L. Richard    Implemented gTALK.                 */
/*  2.2   20 Apr 98  A. Conwell    Chgd loop traversal per Tisk 30    */
/*--------------------------------------------------------------------*/

/*==[ INTERFACE ]=====================================================*/

#include "r2.h" 
#include "r2select.h"

/*==[ PRIVATE IMPLEMENTATION ]========================================*/

#include "r2util.h"

/*==[ PUBLIC IMPLEMENTATION ]=========================================*/

/*--------------------------------------------------------------------*/
/*  FUNCTION	SelectComp                                            */
/*--------------------------------------------------------------------*/

extern BOOL SelectComp(
  COMPLIST	*cl,			/* Component list	      */
  int		*thresh			/* Functionality threshold    */
)
{
  COMPELEM	*elem;			/* Component node	      */
  COMPNODE      *node;			/* Component 'pkg' for btree  */
  int		ratio;			/* Functionality occurance    */

  if (cl==NULL)
    return( TRUE );

  /* Iterate over the entire list */
  node=get_first_node(cl);

  do
  {
    elem=(COMPELEM *)(node->key);
    node=get_successor(node);
    ratio = 100 * elem->With / elem->Tot;	/* Calculate actual ratio     */
    if (ratio < *thresh)		/* Compare against threshold  */
      RemoveCompElem(cl,elem);
  } while (node->key!=NULL);


  if (2 == gTALK)
    ShowCompList( cl, "Selected CL" );

  if (CompListSize( cl ) <= 0)
  {
    /* Empty lists are invalid    */
    if (0 < gTALK)
      printf( "R2Analyz: No components meet selection criteria!\n" );
    return( TRUE );
  }
  else
    return( FALSE );

} /* SelectComp() */

/*====================================================================*/
/*  EOF    :  r2select.c                                              */
/*====================================================================*/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -