-
Notifications
You must be signed in to change notification settings - Fork 298
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- improve Simplification of Add operations by using HashTable instead…
… of comparing all Elements in the list by List seach git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@15456 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
- Loading branch information
Jens Frenkel
committed
Mar 4, 2013
1 parent
df214de
commit 14aead2
Showing
3 changed files
with
176 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
encapsulated package HashTableExpToReal " | ||
This file is an extension to OpenModelica. | ||
|
||
Copyright (c) 2013 TU Dresden | ||
|
||
All rights reserved. | ||
|
||
file: HashTableExpToReal.mo | ||
package: HashTableExpToReal | ||
description: DAE.Exp to Integer | ||
|
||
RCS: $Id: HashTableExpToReal.mo 15361 2013-02-27 15:44:14Z lochel $ | ||
|
||
" | ||
|
||
/* Below is the instance specific code. For each hashtable the user must define: | ||
Key - The key used to uniquely define elements in a hashtable | ||
Value - The data to associate with each key | ||
hashFunc - A function that maps a key to a positive integer. | ||
keyEqual - A comparison function between two keys, returns true if equal. | ||
*/ | ||
|
||
/* HashTable instance specific code */ | ||
|
||
public import BaseHashTable; | ||
public import DAE; | ||
protected import Expression; | ||
protected import ExpressionDump; | ||
|
||
public type Key = DAE.Exp; | ||
public type Value = Real; | ||
|
||
public type HashTableCrefFunctionsType = tuple<FuncHashCref,FuncCrefEqual,FuncCrefStr,FuncExpStr>; | ||
public type HashTable = tuple< | ||
array<list<tuple<Key,Integer>>>, | ||
tuple<Integer,Integer,array<Option<tuple<Key,Value>>>>, | ||
Integer, | ||
Integer, | ||
HashTableCrefFunctionsType | ||
>; | ||
|
||
partial function FuncHashCref | ||
input Key cr; | ||
input Integer mod; | ||
output Integer res; | ||
end FuncHashCref; | ||
|
||
partial function FuncCrefEqual | ||
input Key cr1; | ||
input Key cr2; | ||
output Boolean res; | ||
end FuncCrefEqual; | ||
|
||
partial function FuncCrefStr | ||
input Key cr; | ||
output String res; | ||
end FuncCrefStr; | ||
|
||
partial function FuncExpStr | ||
input Value exp; | ||
output String res; | ||
end FuncExpStr; | ||
|
||
public function emptyHashTable | ||
" | ||
Returns an empty HashTable. | ||
Using the default bucketsize.. | ||
" | ||
output HashTable hashTable; | ||
algorithm | ||
hashTable := emptyHashTableSized(BaseHashTable.defaultBucketSize); | ||
end emptyHashTable; | ||
|
||
public function emptyHashTableSized | ||
" | ||
Returns an empty HashTable. | ||
Using the bucketsize size. | ||
" | ||
input Integer size; | ||
output HashTable hashTable; | ||
algorithm | ||
hashTable := BaseHashTable.emptyHashTableWork(size,(Expression.hashExpMod,Expression.expEqual,ExpressionDump.printExpStr,realString)); | ||
end emptyHashTableSized; | ||
|
||
end HashTableExpToReal; |