コード例 #1
0
ファイル: cvx.cpp プロジェクト: DentonW/CurveSnap
bool IsCompletelyGray(cv::Mat mat)
{
	if (mat.channels() == 1)
		return true;
	else if (mat.channels() == 3)
	{
		std::vector<cv::Mat> v;
		cv::split(mat, v);

		return IsSame(v[0], v[1]) && IsSame(v[0], v[2]);
	}
	else
		throw "channels not 1 or 3.";
}
コード例 #2
0
ファイル: k-hop-main.cpp プロジェクト: cherryunix/k-hop-reach
bool BiRch_BTL(dStruct::node *startNode, dStruct::node *endNode, int step)
{
	if (IsSame(startNode,endNode))
		return true;
	if (step == 0)
		return false;
	if ((((*endNode).depth.first - (*startNode).depth.first) > step) || (((*startNode).depth.second - (*endNode).depth.second) > step))
		return false;
	if (((*startNode).topOrder.first >= (*endNode).topOrder.first) || ((*startNode).topOrder.second >= (*endNode).topOrder.second))
		return false;
	if ((*startNode).OutDeg < (*endNode).InDeg)
	{
		for (std::vector<int>::iterator it = (*startNode).next_node.begin(); it != (*startNode).next_node.end(); ++it)
		{
			dStruct::node *tmpNode = &VertexSet[*it];
			if (BiRch_BTL(tmpNode, endNode, step - 1))
				return true;
		}
	}
	else
	{
		for (std::vector<int>::iterator it = (*endNode).prev_node.begin(); it != (*endNode).prev_node.end(); ++it)
		{
			dStruct::node *tmpNode = &VertexSet[*it];
			if (BiRch_BTL(startNode, tmpNode, step - 1))
				return true;
		}
	}
	return false;
}
コード例 #3
0
ファイル: Process.cpp プロジェクト: SergeyStrukov/CCore
void TopParser::next(TypeDef::Atom *atom,TypeDef::TopRule *rule)
 {
  TypeDef::State *state=topState();
  
  TypeDef::Rule *bottom_rule=Find(state->final->actions,atom);
  
  if( rule->bottom!=bottom_rule )
    {
     Printf(Exception,"App::TopParser::next(...) : rule mismatch");
    }
  
  auto args=rule->args.getRange();
  
  auto *ptr=topElements(args.len);

  for(auto p=args; +p ;++p,++ptr)
    {
     if( !IsSame(ptr->element,*p) )
       {
        Printf(Exception,"App::TopParser::next(...) : bad stack");
       }
    }
  
  pop(args.len);
  
  TypeDef::Kind *result=rule->result;
  
  push(result,Transition(topState()->transitions,result));
 }
コード例 #4
0
long ssdtableUpdate(DespTag tag, unsigned long hash_code, long despId)
{
	if (DEBUG)
		printf("[INFO] Insert tag: %lu, hash_code=%lu\n",tag.offset, hash_code);
	SSDHashBucket* nowbucket = GetSSDHashBucket(hash_code);
	SSDHashBucket* lastbucket = nowbucket;
	while (nowbucket != NULL) {
        lastbucket = nowbucket;
        if (IsSame(nowbucket->hash_key,tag)) {
            long oldId = nowbucket->despId;
            nowbucket->despId = despId;
            return oldId;
		}
		nowbucket = nowbucket->next_item;
	}

	// if not exist in table, insert one.

    SSDHashBucket* newitem = memPop();
    newitem->hash_key = tag;
    newitem->despId = despId;
    newitem->next_item = NULL;
    lastbucket->next_item = newitem;
	return -1;
}
コード例 #5
0
ファイル: triangle_2.c プロジェクト: biergaizi/My-files
int generate(int sum, int (* result)[3]) {
    int a;
    int b = 1;
    int c;
    int counter = -1;
    
    for (a = 1; (sum - a - b) > 0; a++) {
        for (c = 2; c > 1; b++) {
            c = sum - a - b;
            //printf("a=%i, b=%i, c=%i\n", a, b, c);
            if (!(IsSame(a, b, c))) {
                counter++;
                result[counter][0] = a;
                result[counter][1] = b;
                result[counter][2] = c;
            }
        }
	if ((a == b) && (b == c)) {
        printf("Breaked!");
	    break;
	}

        b = 1;
    }
    return 0;
}
コード例 #6
0
ファイル: CanvasTextFormat.cpp プロジェクト: davidni/Win2D
    HRESULT __declspec(nothrow) CanvasTextFormat::PropertyPut(T value, TT* dest, FNV&& validator, void(CanvasTextFormat::*realizer)())
    {
        return ExceptionBoundary(
            [&]
            {
                validator(value);

                ThrowIfClosed();

                if (IsSame(dest, value))
                {
                    // Don't do anything if the value we're setting is the same
                    // as the current value.
                    return;
                }

                if (!realizer)
                {
                    // If there's no realizer set then we're going to have to
                    // throw away m_format (ready to be recreated the next time
                    // it is needed)
                    Unrealize();
                }

                // Set the shadow value
                SetFrom(dest, value);

                // Realize the value on the dwrite object, if we can
                if (m_format && realizer)
                    (this->*realizer)();
            });
    }
コード例 #7
0
ファイル: RadioSet.cpp プロジェクト: mygaldre/mmvari
//---------------------------------------------------------------------------
void __fastcall TRADIOSetDlg::SetMaker(void)
{
	int i;
	for( i = 0; __MK[i] != NULL; i++ ){
		if( IsSame(AnsiString(CmdRx->Text).c_str(), __MT[i][1]) && IsSame(AnsiString(CmdTx->Text).c_str(), __MT[i][2]) && IsCompatible (m_PollType,i)){       //AA6YQ 1.66	JA7UDE 0428
			m_DisEvent++;
			Maker->Text = __MK[i];
			m_DisEvent--;
			m_Maker = i;
			SetVFOList();
			return;
		}
	}
	m_Maker = MAKER_UNKNOWN;
	m_DisEvent++;
	Maker->Text = "Unknown";
	SetVFOList();
	m_DisEvent--;
}
コード例 #8
0
gp_Pnt GetCentralFacePoint(const TopoDS_Face& face)
{
    // compute point on face
    Standard_Real umin, umax, vmin, vmax;

    gp_Pnt p;

    Handle(Geom_Surface) surface = BRep_Tool::Surface(face);
    BRepTools::UVBounds(face, umin, umax, vmin, vmax);
    Standard_Real umean = 0.5*(umin+umax);
    Standard_Real vmean = 0.5*(vmin+vmax);


    // compute intersection of u-iso line with face boundaries
    Handle(Geom2d_Curve) uiso = new Geom2d_Line(
                gp_Pnt2d(umean,0.),
                gp_Dir2d(0., 1.)
                );

    TopExp_Explorer exp (face,TopAbs_EDGE);
    std::list<double> intersections;
    for (; exp.More(); exp.Next()) {
        TopoDS_Edge edge = TopoDS::Edge(exp.Current());
        Standard_Real first, last;

        // Get geomteric curve from edge
        Handle(Geom2d_Curve) hcurve = BRep_Tool::CurveOnSurface(edge, face, first, last);
        hcurve = new Geom2d_TrimmedCurve(hcurve, first, last);

        Geom2dAPI_InterCurveCurve intersector(uiso, hcurve);
        for (int ipoint = 0; ipoint < intersector.NbPoints(); ++ipoint) {
            gp_Pnt2d p = intersector.Point(ipoint+1);
            intersections.push_back(p.Y());
        }
    }

    // remove duplicate solutions defined by tolerance
    double tolerance = 1e-5;
    intersections.sort();
    intersections.unique(IsSame((vmax-vmin)*tolerance));

    // normally we should have at least two intersections
    // also the number of sections should be even - else something is really strange
    //assert(intersections.size() % 2 == 0);
    if (intersections.size() >= 2) {
        std::list<double>::iterator it = intersections.begin();
        double int1 = *it++;
        double int2 = *it;
        vmean = (int1 + int2)/2.;
    }

    surface->D0(umean, vmean, p);

    return p;
}
コード例 #9
0
BOOL Mac::CheckRecord()
{
	for(int i=0; i<CUR_IP_MAC_LEN; i++)
	{
		if(IsSame(IP_MAC_STABLE[i].IP, DestIpAddr, 4))
		{
			MoveMemory(DestMacAddr, IP_MAC_STABLE[i].MAC, 6);
			return TRUE;
		}
	}
	return FALSE;
}
コード例 #10
0
ファイル: test.c プロジェクト: voidrank/cJson
int TestSomeFuncs() {
	
	int score = 10;
	
	// 调用同学们实现的接口
	JSON *root = CreateObject();
	// 评测1 是否能正确创建Object
	if (root->type != JSON_OBJECT) { // 类型不对
		score -= 2;
	}
	
	AddItemToObject(root, "name", CreateString("Hello World"));
	// 评测2 是否能正确AddItemToObject并且读取
	JSON *value = GetItemInObject(root, "name");
	// 类型不对或者值不对
	if (value->type != JSON_STRING || strcmp(value->valuestring, "Hello World")) {
		score -= 2;
	}
	
	JSON *array = CreateArray();
	AddItemToArray(array, CreateBool(0));
	AddItemToArray(array, CreateNumber(2.3));
	// 评测3 是否能正确AddItemToArray并且读取
	JSON *item = GetItemInArray(array, 1);
	if (item->type != JSON_NUMBER || item->valuedouble != 2.3) {
		score -= 2;
	}
	
	AddItemToObject(root, "array", courses);
	// 现在root的状态
	/*
	{
		"name": "Hello Wrold",
		"array": [
			false,
			2.3
		]
	}
	*/
	
	// 评测4 是否能正确地根据路径读取值
	item = GetItemInJSON(root, "/array/0");
	if (item->type != JSON_FALSE) {
		score -= 2;
	}
	
	PrintJSONToFile(root, "test.json");
	// 评测5 是否与标准答案文件相同
	if (!IsSame("test.json", "test.json.ans")) {
		score -= 2;
	}
	return score;
}
コード例 #11
0
ファイル: PictureTest.cpp プロジェクト: SummerSnail2014/haiku
bool
PictureTest::Test(draw_func* func, BRect frame)
{
	CleanUp();

	fDirectBitmap = CreateBitmap(func, frame);
	TEST_AND_RETURN(fDirectBitmap == NULL, "Could not create direct draw bitmap!", false);

	BPicture *picture = RecordPicture(func, frame);
	AutoDelete<BPicture> _picture(picture);
	TEST_AND_RETURN(picture == NULL, "Picture could not be recorded!", false);
		
	BPicture *archivedPicture = SaveAndRestore(picture);
	AutoDelete<BPicture> _archivedPicture(archivedPicture);
	TEST_AND_RETURN(picture == NULL, "Picture could not be flattened and unflattened!", false);
	
	fBitmapFromPicture = CreateBitmap(picture, frame);
	TEST_AND_RETURN(fBitmapFromPicture == NULL, "Could not create bitmap from original picture!", false);
		
	fBitmapFromRestoredPicture = CreateBitmap(archivedPicture, frame);
	TEST_AND_RETURN(fBitmapFromRestoredPicture == NULL, "Could not create bitmap from archived picture!", false);
	
	BString reason;
	if (!IsSame(fDirectBitmap, fBitmapFromPicture, reason)) {
		BString message("Bitmap from picture differs from direct drawing bitmap: ");
		message += reason;
		SetErrorMessage(message.String());
		return false;
	}
	if (!IsSame(fDirectBitmap, fBitmapFromRestoredPicture, reason)) {
		BString message("Bitmap from restored picture differs from direct drawing bitmap: ");
		message += reason;
		SetErrorMessage(message.String());
		return false;
	}
	return true;
}
コード例 #12
0
long ssdtableLookup(DespTag tag, unsigned long hash_code)
{
	if (DEBUG)
		printf("[INFO] Lookup tag: %lu\n",tag.offset);
	SSDHashBucket *nowbucket = GetSSDHashBucket(hash_code);
	while (nowbucket != NULL) {
	//	printf("nowbucket->buf_id = %u %u %u\n", nowbucket->hash_key.rel.database, nowbucket->hash_key.rel.relation, nowbucket->hash_key.block_num);
		if (IsSame(nowbucket->hash_key, tag)) {
	//		printf("find\n");
			return nowbucket->despId;
		}
		nowbucket = nowbucket->next_item;
	}
//	printf("no find\n");

	return -1;
}
コード例 #13
0
ファイル: INSTR.cpp プロジェクト: JFreaker/exetoc
bool st_InstrAddOn::IsSame(st_InstrAddOn* p1, st_InstrAddOn* p2)
{   //static function
    if (p1 == NULL)
    {
        return (p2 == NULL);
    }
    if (p2 == NULL)
        return false;
    //现在,两个都不是NULL了
    if (p1->type != p2->type)
        return false;
    if (p1->type == IA_AddImmed || p1->type == IA_MulImmed)
    {
        if (p1->addimmed.iAddon != p2->addimmed.iAddon)
            return false;
    }
    return IsSame(p1->pChild, p2->pChild);
}
コード例 #14
0
long ssdtableDelete(DespTag tag, unsigned long hash_code)
{
	if (DEBUG)
		printf("[INFO] Delete tag: %lu, hash_code=%lu\n",tag.offset, hash_code);
	SSDHashBucket *nowbucket = GetSSDHashBucket(hash_code);
	long del_id;
	SSDHashBucket *delitem;

	while (nowbucket->next_item != NULL) {
		if (IsSame(nowbucket->next_item->hash_key, tag)) {
            delitem = nowbucket->next_item;
            del_id = delitem->despId;
            nowbucket->next_item = delitem->next_item;
            memPush(delitem);
            return del_id;
		}
		nowbucket = nowbucket->next_item;
	}

	return -1;
}
コード例 #15
0
void CRuleManager::AppendFavRule(const TDesC& aName,const TUid& aUid, const TInt& aType, const TInt& aCountDown, 
		const TTime& aTime)
	{
	if (iFavRule == NULL)
		return;
	
	if (IsSame(aName,aUid,aType,aCountDown,aTime))
		{
		iFavRule->IncreaseFavCount();
		}
	else
		{
		iFavRule->SetName(aName);
		iFavRule->SetUid(aUid);
		iFavRule->SetType(aType);
		iFavRule->SetCountDown(aCountDown);
		iFavRule->SetClock(aTime);
		iFavRule->SetFavCount(0);
		}
	
	WriteFavToFile();
	}
コード例 #16
0
//=============================================================================
void PutLogFileList(const char * cStr, char *FileName)
{
 FILE * pFile;
 char cBuffer[MAXLOGLINESIZE+100];
 SYSTEMTIME SysTime;

        _mkdir("Logs");
		if(strlen(cStr) > MAXLOGLINESIZE) return;
        if(FileName == NULL) pFile = fopen(EVENT_LOGFILE, "at");
        else if(IsSame(FileName, XSOCKET_LOGFILE)) pFile = fopen(FileName, "ab");
		else pFile = fopen(FileName, "at");
	if (pFile == NULL) return;

	ZeroMemory(cBuffer, sizeof(cBuffer));

	GetLocalTime(&SysTime);
	wsprintf(cBuffer, "(%4d:%2d:%2d:%2d:%2d) - ", SysTime.wYear, SysTime.wMonth, SysTime.wDay, SysTime.wHour, SysTime.wMinute);
	strcat(cBuffer, cStr);
	strcat(cBuffer, "\n");

	fwrite(cBuffer, 1, strlen(cBuffer), pFile);
	fclose(pFile);
}
コード例 #17
0
/**
   Checks whether the given string starts with the prefix and returns the
   remainder of the string in this case.

   @param str the string to examine
   @param prefix the prefix to detect and possibly remove
   @param cs case sensitivity: if Case_Ignore, prefix is matched ignoring case
   @param rest if non-NULL is filled with the remaining part of the string
               (after prefix) if the return value is true and becomes empty
               otherwise
   @return true if str starts with prefix
 */
static bool
StringStartsWith(const String& str,
                 const wxChar *prefix,
                 CaseSensitivity cs = Case_Exact,
                 String *rest = NULL)
{
   const wxChar *p = str.c_str();
   while ( *prefix )
   {
      if ( !IsSame(*prefix++, *p++, cs) )
      {
         // no match
         if ( rest )
            rest->clear();
         return false;
      }
   }

   if ( rest )
      *rest = p;

   return true;
}
コード例 #18
0
bool AbstractCellProperty::IsSame(boost::shared_ptr<const AbstractCellProperty> pOther) const
{
    return IsSame(pOther.get());
}
コード例 #19
0
ファイル: cvx.cpp プロジェクト: DentonW/CurveSnap
bool IsContainedBin(const cv::Mat container, const cv::Mat mat)
{
    return IsSame(container & mat, mat);
}
コード例 #20
0
ファイル: execForwardList.C プロジェクト: bbannier/roottest
void checkObjects(const char* name, const T& a, const T& b){
   if (IsSame(a,b)) return;
   std::cerr << "Objects called " << name << " differ!\n";
}
コード例 #21
0
ファイル: CComputer.cpp プロジェクト: heavyair/testjni
bool CComputer::operator ==(const CComputer& d) {
	return IsSame(d);
}
コード例 #22
0
ファイル: CanvasTextFormat.cpp プロジェクト: davidni/Win2D
 static bool IsSame(ABI::Windows::UI::Text::FontWeight* outputValue, ABI::Windows::UI::Text::FontWeight const& value)
 {
     return IsSame(&outputValue->Weight, value.Weight);
 }