/// <summary> /// すべてのObjectにGetDataHash()を定義 /// デフォルトではGetHashCode()を返す /// </summary> /// <param name="data"></param> /// <returns></returns> public static int GetDataHash(this System.Object data) { var unityObj = data as UnityEngine.Object; if (!object.ReferenceEquals(unityObj, null)) { if (unityObj != null) { if (unityObj is Transform) { return((unityObj as Transform).name.GetHashCode()); } else if (unityObj is GameObject) { return((unityObj as GameObject).name.GetHashCode()); } else if (unityObj is Mesh) { // 頂点リストとトライアングルリストを調べる var mesh = unityObj as Mesh; int hash = 0; hash += mesh.vertexCount.GetDataHash(); // 頂点数のみでよい hash += mesh.triangles.Length.GetDataHash(); // トライアングル数のみでよい hash += mesh.subMeshCount.GetDataHash(); hash += mesh.isReadable.GetDataHash(); return(hash); } else { return(NumberHash + data.GetHashCode()); } } else { return(NullHash); } } else { if (data != null) { return(NumberHash + data.GetHashCode()); } else { return(NullHash); } } }
public void removeAllActionsFromTarget(System.Object target) { if (target == null) { return; } tHashElement element = _targets.HASH_FIND_INT(target.GetHashCode()); if (element != null) { if (element.actions.Contains(element.currentAction) && !element.currentActionSalvaged) { element.currentActionSalvaged = true; } element.actions.Clear(); if (_currentTarget == element) { _currentTargetSavlvaged = true; } else { deleteHashElement(element); } } }
public void pauseTarget(System.Object target) { tHashElement element = _targets.HASH_FIND_INT(target.GetHashCode()); if (element != null) { element.paused = true; } }
public uint numberOfRunningActionsInTarget(System.Object target) { tHashElement element = _targets.HASH_FIND_INT(target.GetHashCode()); if (element != null && element.actions != null) { return((uint)(element.actions.Count)); } return(0); }
void DoProcess() { if (!(owner.Value is OpenCVForUnityPlayMakerActions.OpenCVObject)) { LogError("owner is not initialized. Add Action \"newClassName\"."); return; } System.Object wrapped_owner = OpenCVForUnityPlayMakerActionsUtils.GetWrappedObject <OpenCVForUnityPlayMakerActions.OpenCVObject, System.Object>(owner); storeResult.Value = wrapped_owner.GetHashCode(); }
void DoProcess() { if (!(owner.Value is DlibFaceLandmarkDetectorPlayMakerActions.DlibObject)) { LogError("owner is not initialized. Add Action \"newClassName\"."); return; } System.Object wrapped_owner = DlibFaceLandmarkDetectorPlayMakerActionsUtils.GetWrappedObject <DlibFaceLandmarkDetectorPlayMakerActions.DlibObject, System.Object> (owner); storeResult.Value = wrapped_owner.GetHashCode(); }
public override int GetHashCode() { int h = 0; for (Iterator it = iterator(); it.hasNext();) { System.Object e = it.next(); h = (h + (e == null ? 0 : e.GetHashCode())) & -1; } return(h); }
public override int GetHashCode() { int hashCode = 1; int s = size(); for (int i = 0; i < s; i++) { System.Object e = get(i); hashCode = (31 * hashCode + (e == null ? 0 : e.GetHashCode())) & (-1); } return(hashCode); }
// -(NSSet *) pauseAllRunningActions // { // NSMutableSet* idsWithActions = [NSMutableSet setWithCapacity:50]; // // for(tHashElement *element=targets; element != NULL; element=element->hh.next) { // if( !element->paused ) { // element->paused = YES; // [idsWithActions addObject:element->target]; // } // } // return idsWithActions; // } // // -(void) resumeTargets:(NSSet *)targetsToResume // { // for(id target in targetsToResume) { // [self resumeTarget:target]; // } // } #endregion #region ActionManager - run public void addAction(CCAction action, System.Object target, bool paused) { NSUtils.Assert(action != null, "Argument action must be non-nil"); NSUtils.Assert(target != null, "Argument target must be non-nil"); tHashElement element = _targets.HASH_FIND_INT(target.GetHashCode()); if (element == null) { element = new tHashElement(); element.paused = paused; element.target = target; _targets.HASH_ADD_INT(target.GetHashCode(), element); } actionAllocWithHashElement(element); NSUtils.Assert(!element.actions.Contains(action), "runAction: Action already running"); element.actions.Add(action); action.startWithTarget(target); }
private string GetUUID(System.Object obj) { int unityHash = obj.GetHashCode(); int newHash; if (this._uuidDic.TryGetValue(unityHash, out newHash)) { return(newHash.ToString()); } newHash = this._uuidIndex++; this._uuidDic[unityHash] = newHash; return(newHash.ToString()); }
public override int GetHashCode() { int sum = 0; for (Iterator it = this.keySet().iterator(); it.hasNext();) { System.Object k = it.next(); System.Object v = get(k); int c = (k == null ? 0 : k.GetHashCode()) ^ (v == null ? 0 : v.GetHashCode()); sum = (sum + c) & -1; } return(sum); }
public void removeAction(CCAction action) { if (action == null) { return; } System.Object target = action.originalTarget; tHashElement element = _targets.HASH_FIND_INT(target.GetHashCode()); if (element != null) { int i = element.actions.IndexOf(action); if (i != -1) { removeActionAtIndex(i, element); } } }
public CCAction getActionByTag(int aTag, System.Object target) { NSUtils.Assert(aTag != CCAction.kCCActionTagInvalid, "Invalid tag"); tHashElement element = _targets.HASH_FIND_INT(target.GetHashCode()); if (element != null) { if (element.actions != null) { int limit = element.actions.Count; for (int i = 0; i < limit; i++) { CCAction a = element.actions[i]; if (a.tag == aTag) { return(a); } } } } return(null); }
public void removeActionByTag(int aTag, System.Object target) { NSUtils.Assert(aTag != CCAction.kCCActionTagInvalid, "Invalid tag"); NSUtils.Assert(target != null, "Target should be null !"); tHashElement element = _targets.HASH_FIND_INT(target.GetHashCode()); if (element != null) { if (element.actions != null) { int limit = element.actions.Count; for (int i = 0; i < limit; i++) { CCAction a = element.actions[i]; if (a.tag == aTag && a.originalTarget == target) { removeActionAtIndex(i, element); break; } } } } }
// =========================================================== // Methods // =========================================================== public void Add(System.Object obj) { currentHash += currentHash * secondPrime + (obj != null ? obj.GetHashCode() : 0); }
static string GenerateLogMessage(string type, System.Object obj, string message) { return(GenerateLogMessage(type, "{0}][{1}".FormatInvarient(obj.GetType().FullName, obj.GetHashCode().ToString("X")), message)); }
public int hashKey() { return(target.GetHashCode()); }
/// <summary> Tests a CacheEntry[] for indication of "insane" cache usage. /// <p/> /// NOTE:FieldCache CreationPlaceholder objects are ignored. /// (:TODO: is this a bad idea? are we masking a real problem?) /// <p/> /// </summary> public Insanity[] Check(CacheEntry[] cacheEntries) { if (null == cacheEntries || 0 == cacheEntries.Length) { return(new Insanity[0]); } if (null != ramCalc) { for (int i = 0; i < cacheEntries.Length; i++) { cacheEntries[i].EstimateSize(ramCalc); } } // the indirect mapping lets MapOfSet dedup identical valIds for us // // maps the (valId) identityhashCode of cache values to // sets of CacheEntry instances MapOfSets <int, CacheEntry> valIdToItems = new MapOfSets <int, CacheEntry>(new Dictionary <int, Dictionary <CacheEntry, CacheEntry> >(17)); // maps ReaderField keys to Sets of ValueIds MapOfSets <ReaderField, int> readerFieldToValIds = new MapOfSets <ReaderField, int>(new Dictionary <ReaderField, Dictionary <int, int> >(17)); // // any keys that we know result in more then one valId // TODO: This will be a HashSet<T> when we start using .NET Framework 3.5 Dictionary <ReaderField, ReaderField> valMismatchKeys = new Dictionary <ReaderField, ReaderField>(); // iterate over all the cacheEntries to get the mappings we'll need for (int i = 0; i < cacheEntries.Length; i++) { CacheEntry item = cacheEntries[i]; System.Object val = item.GetValue(); if (val is Lucene.Net.Search.CreationPlaceholder) { continue; } ReaderField rf = new ReaderField(item.GetReaderKey(), item.GetFieldName()); System.Int32 valId = val.GetHashCode(); // indirect mapping, so the MapOfSet will dedup identical valIds for us valIdToItems.Put(valId, item); if (1 < readerFieldToValIds.Put(rf, valId)) { if (!valMismatchKeys.ContainsKey(rf)) { valMismatchKeys.Add(rf, rf); } } } List <Insanity> insanity = new List <Insanity>(valMismatchKeys.Count * 3); insanity.AddRange(CheckValueMismatch(valIdToItems, readerFieldToValIds, valMismatchKeys)); insanity.AddRange(CheckSubreaders(valIdToItems, readerFieldToValIds)); return(insanity.ToArray()); }
public static void LogError(this System.Object obj, string message) { Debug.LogError("-ERROR- " + obj.GetType().FullName + "[" + obj.GetHashCode().ToString("X") + "][" + Time.time.ToString("0.00") + "]: " + message); }
public override int GetHashCode() { return(readerKey.GetHashCode() * fieldName.GetHashCode()); }