AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren

const foo: array of TMyRecord = (myArray:???)

Ein Thema von yankee · begonnen am 12. Mai 2010 · letzter Beitrag vom 12. Mai 2010
 
Benutzerbild von yankee
yankee

Registriert seit: 10. Mär 2004
1.134 Beiträge
 
Lazarus
 
#6

Re: const foo: array of TMyRecord = (myArray:???)

  Alt 12. Mai 2010, 13:49
Zitat von himitsu:
Du weißt aber, daß JSON eh keine "echten" Konstanten kennt, da es "nur" ein Format einer ScriptSprache ist und somit alles "nur" dynamisch verwaltet wird.
(dieses JSON-String wird da auch erst zur Laufzeit über einen Parser zerlegt)
Ja, das ist schon klar, ich habe das nur als JSON geschrieben um zu verdeutlichen, was ich nachher im Speicher stehen haben will. Nur um eine Vorstellung zu vermitteln. Ich hätte es natürlich auch auf deutsch ausformulieren können, aber das wäre dann vermutlich auch schlecht zu verstehen gewesen.

Ich habe rein zu Demonstrationszwecken den KMP-Algorithmus implementiert und ein paar einfach test cases geschrieben, die ich einfach zu Demonstrationszwecken drüberrasseln lassen kann.

Delphi-Quellcode:
// == Defining test cases == //
// 1. testcase (pattern + text is identical)
  testCases[0].pattern := 'aababaab';
  testCases[0].text := testCases[0].pattern; // text and pattern is identical
  // there should be exactly one occurence at the first character of the string
  SetLength(testCases[0].occurences, 1);
  testCases[0].occurences[0] := 1;
// 2. testcase (pattern occures somewhere in the middle)
  testCases[1].pattern := 'aababaab';
  testCases[1].text := 'aaa' + testCases[1].pattern + 'aaa';
  // there should be exactly one occurence at the fourth character of the string
  SetLength(testCases[1].occurences, 1);
  testCases[1].occurences[0] := 4;
// 3. testcase: (pattern does not occur in the string)
  testCases[2].pattern := 'aababaab';
  testCases[2].text := 'aaaaaabbbbbbbbaaaabbbbhhhhhaaadddd';
  // there should be no occurences
  SetLength(testCases[2].occurences, 0);
// 4. testcase: (pattern occures several time without overlapping each other)
  testCases[3].pattern := 'aababaab';
  testCases[3].text := 'aa' + testCases[3].pattern + 'a' + testCases[3].pattern;
  // there should be two occurences at the 3rd and 12th character of the string
  SetLength(testCases[3].occurences, 2);
  testCases[3].occurences[0] := 3;
  testCases[3].occurences[1] := 12;
// 5. testcase (pattern occures several times with overlapping each other)
  testCases[4].pattern := 'aababaab';
  testCases[4].text := 'aababaababaab';
  // there should be two occurences at the 1st and 6th character of the string
  SetLength(testCases[4].occurences, 2);
  testCases[4].occurences[0] := 1;
  testCases[4].occurences[1] := 6;
// DONE: Building test cases
Gut, geht natürlich. Aber so richtig hyperübersichtlich ist es dann finde ich doch nicht. Vorallem, weil es auch etwas fehleranfällig ist, wenn man einmal sich beim setlength vertut oder bei einem array index. Das könnte man ja theoretisch auch automatisch auflösen. Also wenn da noch wer eine Idee hat...
Letzter Tipp: Drogen. Machen zwar nicht glücklich, geben einem aber wenigstens das Gefühl glücklich zu sein.

Have a lot of fun!
  Mit Zitat antworten Zitat
 

Themen-Optionen Thema durchsuchen
Thema durchsuchen:

Erweiterte Suche
Ansicht

Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 04:43 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz